@layr-labs/ecloud-sdk 0.1.0-dev.2 → 0.1.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/VERSION +2 -2
- package/dist/billing.cjs +536 -0
- package/dist/billing.cjs.map +1 -0
- package/dist/billing.d.cts +20 -0
- package/dist/billing.d.ts +20 -0
- package/dist/billing.js +8 -0
- package/dist/billing.js.map +1 -0
- package/dist/chunk-6WSXUSKJ.js +668 -0
- package/dist/chunk-6WSXUSKJ.js.map +1 -0
- package/dist/chunk-COKPE6TJ.js +180 -0
- package/dist/chunk-COKPE6TJ.js.map +1 -0
- package/dist/chunk-RDONKJY6.js +6289 -0
- package/dist/chunk-RDONKJY6.js.map +1 -0
- package/dist/compute-B_ibIORD.d.cts +184 -0
- package/dist/compute-gpepEsn3.d.ts +184 -0
- package/dist/compute.cjs +6242 -0
- package/dist/compute.cjs.map +1 -0
- package/dist/compute.d.cts +3 -0
- package/dist/compute.d.ts +3 -0
- package/dist/compute.js +16 -0
- package/dist/compute.js.map +1 -0
- package/dist/index-D-SUX3IG.d.cts +218 -0
- package/dist/index-D-SUX3IG.d.ts +218 -0
- package/dist/index.cjs +943 -537
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +238 -395
- package/dist/index.d.ts +238 -395
- package/dist/index.js +96 -6643
- package/dist/index.js.map +1 -1
- package/package.json +12 -1
package/dist/index.cjs
CHANGED
|
@@ -30,18 +30,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
NoopClient: () => NoopClient,
|
|
33
34
|
PRIMARY_LANGUAGES: () => PRIMARY_LANGUAGES,
|
|
35
|
+
PostHogClient: () => PostHogClient,
|
|
34
36
|
UserApiClient: () => UserApiClient,
|
|
37
|
+
addMetric: () => addMetric,
|
|
38
|
+
addMetricWithDimensions: () => addMetricWithDimensions,
|
|
35
39
|
assertValidFilePath: () => assertValidFilePath,
|
|
36
40
|
assertValidImageReference: () => assertValidImageReference,
|
|
37
41
|
assertValidPrivateKey: () => assertValidPrivateKey,
|
|
38
42
|
checkERC7702Delegation: () => checkERC7702Delegation,
|
|
39
43
|
createApp: () => createApp,
|
|
40
|
-
|
|
44
|
+
createAppEnvironment: () => createAppEnvironment,
|
|
41
45
|
createBillingModule: () => createBillingModule,
|
|
46
|
+
createComputeModule: () => createComputeModule,
|
|
42
47
|
createECloudClient: () => createECloudClient,
|
|
48
|
+
createMetricsContext: () => createMetricsContext,
|
|
49
|
+
createTelemetryClient: () => createTelemetryClient,
|
|
43
50
|
deleteLegacyPrivateKey: () => deleteLegacyPrivateKey,
|
|
44
51
|
deletePrivateKey: () => deletePrivateKey,
|
|
52
|
+
emitMetrics: () => emitMetrics,
|
|
45
53
|
encodeStartAppData: () => encodeStartAppData,
|
|
46
54
|
encodeStopAppData: () => encodeStopAppData,
|
|
47
55
|
encodeTerminateAppData: () => encodeTerminateAppData,
|
|
@@ -65,11 +73,14 @@ __export(index_exports, {
|
|
|
65
73
|
getEnvironmentConfig: () => getEnvironmentConfig,
|
|
66
74
|
getLegacyKeys: () => getLegacyKeys,
|
|
67
75
|
getLegacyPrivateKey: () => getLegacyPrivateKey,
|
|
76
|
+
getPostHogAPIKey: () => getPostHogAPIKey,
|
|
77
|
+
getPostHogEndpoint: () => getPostHogEndpoint,
|
|
68
78
|
getPrivateKey: () => getPrivateKey,
|
|
69
79
|
getPrivateKeyWithSource: () => getPrivateKeyWithSource,
|
|
70
80
|
getTemplate: () => getTemplate,
|
|
71
81
|
isEnvironmentAvailable: () => isEnvironmentAvailable,
|
|
72
82
|
isMainnet: () => isMainnet,
|
|
83
|
+
isNoopClient: () => isNoopClient,
|
|
73
84
|
isSubscriptionActive: () => isSubscriptionActive,
|
|
74
85
|
keyExists: () => keyExists,
|
|
75
86
|
listStoredKeys: () => listStoredKeys,
|
|
@@ -99,11 +110,12 @@ __export(index_exports, {
|
|
|
99
110
|
validateUpgradeParams: () => validateUpgradeParams,
|
|
100
111
|
validateXURL: () => validateXURL,
|
|
101
112
|
watchDeployment: () => watchDeployment,
|
|
102
|
-
watchUpgrade: () => watchUpgrade
|
|
113
|
+
watchUpgrade: () => watchUpgrade,
|
|
114
|
+
withSDKTelemetry: () => withSDKTelemetry
|
|
103
115
|
});
|
|
104
116
|
module.exports = __toCommonJS(index_exports);
|
|
105
117
|
|
|
106
|
-
// src/client/modules/app/index.ts
|
|
118
|
+
// src/client/modules/compute/app/index.ts
|
|
107
119
|
var import_viem9 = require("viem");
|
|
108
120
|
|
|
109
121
|
// src/client/common/config/environment.ts
|
|
@@ -338,10 +350,10 @@ async function checkIfImageAlreadyLayeredForECloud(docker, imageTag) {
|
|
|
338
350
|
return false;
|
|
339
351
|
}
|
|
340
352
|
}
|
|
341
|
-
async function pullDockerImage(docker, imageTag,
|
|
353
|
+
async function pullDockerImage(docker, imageTag, platform2 = "linux/amd64", logger) {
|
|
342
354
|
logger?.info?.(`Pulling image ${imageTag}...`);
|
|
343
355
|
return new Promise((resolve2, reject) => {
|
|
344
|
-
docker.pull(imageTag, { platform }, (err, stream) => {
|
|
356
|
+
docker.pull(imageTag, { platform: platform2 }, (err, stream) => {
|
|
345
357
|
if (err) {
|
|
346
358
|
reject(new Error(`Failed to pull image ${imageTag}: ${err.message}`));
|
|
347
359
|
return;
|
|
@@ -937,9 +949,9 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
|
|
|
937
949
|
const platforms = [];
|
|
938
950
|
for (const m of manifest.manifests) {
|
|
939
951
|
if (m.platform) {
|
|
940
|
-
const
|
|
941
|
-
platforms.push(
|
|
942
|
-
if (
|
|
952
|
+
const platform2 = `${m.platform.os}/${m.platform.architecture}`;
|
|
953
|
+
platforms.push(platform2);
|
|
954
|
+
if (platform2 === DOCKER_PLATFORM) {
|
|
943
955
|
const digest = hexStringToBytes32(m.digest);
|
|
944
956
|
const registry = extractRegistryName(imageRef);
|
|
945
957
|
return {
|
|
@@ -954,7 +966,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
|
|
|
954
966
|
}
|
|
955
967
|
async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
956
968
|
try {
|
|
957
|
-
const { stdout } = await
|
|
969
|
+
const { stdout } = await execFileAsync("docker", ["inspect", imageRef], {
|
|
958
970
|
maxBuffer: 10 * 1024 * 1024
|
|
959
971
|
});
|
|
960
972
|
const inspectData = JSON.parse(stdout);
|
|
@@ -977,8 +989,8 @@ async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
|
977
989
|
}
|
|
978
990
|
throw new Error(`Could not determine platform for ${imageRef}`);
|
|
979
991
|
}
|
|
980
|
-
const
|
|
981
|
-
if (
|
|
992
|
+
const platform2 = `${config.os}/${config.architecture}`;
|
|
993
|
+
if (platform2 === DOCKER_PLATFORM) {
|
|
982
994
|
let digest;
|
|
983
995
|
if (inspectData[0].RepoDigests && inspectData[0].RepoDigests.length > 0) {
|
|
984
996
|
const repoDigest = inspectData[0].RepoDigests[0];
|
|
@@ -995,7 +1007,7 @@ async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
|
995
1007
|
platform: DOCKER_PLATFORM
|
|
996
1008
|
};
|
|
997
1009
|
}
|
|
998
|
-
throw createPlatformErrorMessage(imageRef, [
|
|
1010
|
+
throw createPlatformErrorMessage(imageRef, [platform2]);
|
|
999
1011
|
} catch (error) {
|
|
1000
1012
|
if (error.message.includes("platform")) {
|
|
1001
1013
|
throw error;
|
|
@@ -2513,7 +2525,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
|
2513
2525
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
2514
2526
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
2515
2527
|
function getDefaultClientId() {
|
|
2516
|
-
const version = true ? "0.1.0-dev.
|
|
2528
|
+
const version = true ? "0.1.0-dev.3" : "0.0.0";
|
|
2517
2529
|
return `ecloud-sdk/v${version}`;
|
|
2518
2530
|
}
|
|
2519
2531
|
var UserApiClient = class {
|
|
@@ -5325,7 +5337,202 @@ function validatePrivateKey(key) {
|
|
|
5325
5337
|
}
|
|
5326
5338
|
}
|
|
5327
5339
|
|
|
5328
|
-
// src/client/
|
|
5340
|
+
// src/client/common/telemetry/noop.ts
|
|
5341
|
+
var NoopClient = class {
|
|
5342
|
+
/**
|
|
5343
|
+
* AddMetric implements the TelemetryClient interface
|
|
5344
|
+
*/
|
|
5345
|
+
async addMetric(_metric) {
|
|
5346
|
+
}
|
|
5347
|
+
/**
|
|
5348
|
+
* Close implements the TelemetryClient interface
|
|
5349
|
+
*/
|
|
5350
|
+
async close() {
|
|
5351
|
+
}
|
|
5352
|
+
};
|
|
5353
|
+
function isNoopClient(client) {
|
|
5354
|
+
return client instanceof NoopClient;
|
|
5355
|
+
}
|
|
5356
|
+
|
|
5357
|
+
// src/client/common/telemetry/posthog.ts
|
|
5358
|
+
var import_posthog_node = require("posthog-node");
|
|
5359
|
+
var PostHogClient = class {
|
|
5360
|
+
constructor(environment, namespace, apiKey, endpoint) {
|
|
5361
|
+
this.namespace = namespace;
|
|
5362
|
+
this.appEnvironment = environment;
|
|
5363
|
+
const host = endpoint || "https://us.i.posthog.com";
|
|
5364
|
+
this.client = new import_posthog_node.PostHog(apiKey, {
|
|
5365
|
+
host,
|
|
5366
|
+
flushAt: 1,
|
|
5367
|
+
// Flush immediately for CLI/SDK usage
|
|
5368
|
+
flushInterval: 0
|
|
5369
|
+
// Disable interval flushing
|
|
5370
|
+
});
|
|
5371
|
+
this.client.identify({
|
|
5372
|
+
distinctId: environment.userUUID,
|
|
5373
|
+
properties: {
|
|
5374
|
+
os: environment.os,
|
|
5375
|
+
arch: environment.arch,
|
|
5376
|
+
...environment.cliVersion ? { cliVersion: environment.cliVersion } : {}
|
|
5377
|
+
}
|
|
5378
|
+
});
|
|
5379
|
+
}
|
|
5380
|
+
/**
|
|
5381
|
+
* AddMetric implements the TelemetryClient interface
|
|
5382
|
+
*/
|
|
5383
|
+
async addMetric(metric) {
|
|
5384
|
+
try {
|
|
5385
|
+
const props = {
|
|
5386
|
+
name: metric.name,
|
|
5387
|
+
value: metric.value
|
|
5388
|
+
};
|
|
5389
|
+
for (const [k, v] of Object.entries(metric.dimensions)) {
|
|
5390
|
+
props[k] = v;
|
|
5391
|
+
}
|
|
5392
|
+
this.client.capture({
|
|
5393
|
+
distinctId: this.appEnvironment.userUUID,
|
|
5394
|
+
event: this.namespace,
|
|
5395
|
+
properties: props
|
|
5396
|
+
});
|
|
5397
|
+
} catch {
|
|
5398
|
+
}
|
|
5399
|
+
}
|
|
5400
|
+
/**
|
|
5401
|
+
* Close implements the TelemetryClient interface
|
|
5402
|
+
*/
|
|
5403
|
+
async close() {
|
|
5404
|
+
try {
|
|
5405
|
+
this.client.shutdown();
|
|
5406
|
+
} catch {
|
|
5407
|
+
}
|
|
5408
|
+
}
|
|
5409
|
+
};
|
|
5410
|
+
function getPostHogAPIKey() {
|
|
5411
|
+
if (process.env.ECLOUD_POSTHOG_KEY) {
|
|
5412
|
+
return process.env.ECLOUD_POSTHOG_KEY;
|
|
5413
|
+
}
|
|
5414
|
+
return true ? "phc_BiKfywNft5iBI8N7MxmuVCkb4GGZj4mDFXYPmOPUAI8" : void 0;
|
|
5415
|
+
}
|
|
5416
|
+
function getPostHogEndpoint() {
|
|
5417
|
+
return process.env.ECLOUD_POSTHOG_ENDPOINT || "https://us.i.posthog.com";
|
|
5418
|
+
}
|
|
5419
|
+
|
|
5420
|
+
// src/client/common/telemetry/index.ts
|
|
5421
|
+
var os2 = __toESM(require("os"), 1);
|
|
5422
|
+
|
|
5423
|
+
// src/client/common/telemetry/metricsContext.ts
|
|
5424
|
+
function createMetricsContext() {
|
|
5425
|
+
return {
|
|
5426
|
+
startTime: /* @__PURE__ */ new Date(),
|
|
5427
|
+
metrics: [],
|
|
5428
|
+
properties: {}
|
|
5429
|
+
};
|
|
5430
|
+
}
|
|
5431
|
+
function addMetric(context, name, value) {
|
|
5432
|
+
addMetricWithDimensions(context, name, value, {});
|
|
5433
|
+
}
|
|
5434
|
+
function addMetricWithDimensions(context, name, value, dimensions) {
|
|
5435
|
+
context.metrics.push({
|
|
5436
|
+
name,
|
|
5437
|
+
value,
|
|
5438
|
+
dimensions
|
|
5439
|
+
});
|
|
5440
|
+
}
|
|
5441
|
+
|
|
5442
|
+
// src/client/common/telemetry/index.ts
|
|
5443
|
+
function createTelemetryClient(environment, namespace, options) {
|
|
5444
|
+
const telemetryEnabled = options?.telemetryEnabled === true;
|
|
5445
|
+
if (!telemetryEnabled) {
|
|
5446
|
+
return new NoopClient();
|
|
5447
|
+
}
|
|
5448
|
+
const resolvedApiKey = options?.apiKey || getPostHogAPIKey();
|
|
5449
|
+
if (!resolvedApiKey) {
|
|
5450
|
+
return new NoopClient();
|
|
5451
|
+
}
|
|
5452
|
+
const endpoint = options?.endpoint || getPostHogEndpoint();
|
|
5453
|
+
try {
|
|
5454
|
+
return new PostHogClient(environment, namespace, resolvedApiKey, endpoint);
|
|
5455
|
+
} catch {
|
|
5456
|
+
return new NoopClient();
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
function createAppEnvironment(userUUID, cliVersion, osOverride, archOverride) {
|
|
5460
|
+
return {
|
|
5461
|
+
userUUID,
|
|
5462
|
+
cliVersion,
|
|
5463
|
+
os: osOverride || os2.platform(),
|
|
5464
|
+
arch: archOverride || os2.arch()
|
|
5465
|
+
};
|
|
5466
|
+
}
|
|
5467
|
+
async function emitMetrics(client, context) {
|
|
5468
|
+
if (isNoopClient(client)) {
|
|
5469
|
+
return;
|
|
5470
|
+
}
|
|
5471
|
+
for (const metric of context.metrics) {
|
|
5472
|
+
const dimensions = {
|
|
5473
|
+
...metric.dimensions,
|
|
5474
|
+
...context.properties
|
|
5475
|
+
};
|
|
5476
|
+
const metricWithProperties = {
|
|
5477
|
+
...metric,
|
|
5478
|
+
dimensions
|
|
5479
|
+
};
|
|
5480
|
+
try {
|
|
5481
|
+
await client.addMetric(metricWithProperties);
|
|
5482
|
+
} catch {
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
}
|
|
5486
|
+
|
|
5487
|
+
// src/client/common/telemetry/wrapper.ts
|
|
5488
|
+
var import_crypto = require("crypto");
|
|
5489
|
+
function generateRandomUUID() {
|
|
5490
|
+
return (0, import_crypto.randomUUID)();
|
|
5491
|
+
}
|
|
5492
|
+
async function withSDKTelemetry(options, action) {
|
|
5493
|
+
if (options.skipTelemetry) {
|
|
5494
|
+
return action();
|
|
5495
|
+
}
|
|
5496
|
+
const userUUID = options.userUUID || generateRandomUUID();
|
|
5497
|
+
const environment = createAppEnvironment(userUUID);
|
|
5498
|
+
const client = createTelemetryClient(environment, "ecloud-sdk", {
|
|
5499
|
+
telemetryEnabled: options.telemetryEnabled,
|
|
5500
|
+
apiKey: options.apiKey,
|
|
5501
|
+
endpoint: options.endpoint
|
|
5502
|
+
});
|
|
5503
|
+
const metrics = createMetricsContext();
|
|
5504
|
+
metrics.properties["source"] = "ecloud-sdk";
|
|
5505
|
+
metrics.properties["function"] = options.functionName;
|
|
5506
|
+
if (options.properties) {
|
|
5507
|
+
Object.assign(metrics.properties, options.properties);
|
|
5508
|
+
}
|
|
5509
|
+
addMetric(metrics, "Count", 1);
|
|
5510
|
+
let actionError;
|
|
5511
|
+
let result;
|
|
5512
|
+
try {
|
|
5513
|
+
result = await action();
|
|
5514
|
+
return result;
|
|
5515
|
+
} catch (err) {
|
|
5516
|
+
actionError = err instanceof Error ? err : new Error(String(err));
|
|
5517
|
+
throw err;
|
|
5518
|
+
} finally {
|
|
5519
|
+
const resultValue = actionError ? "Failure" : "Success";
|
|
5520
|
+
const dimensions = {};
|
|
5521
|
+
if (actionError) {
|
|
5522
|
+
dimensions["error"] = actionError.message;
|
|
5523
|
+
}
|
|
5524
|
+
addMetricWithDimensions(metrics, resultValue, 1, dimensions);
|
|
5525
|
+
const duration = Date.now() - metrics.startTime.getTime();
|
|
5526
|
+
addMetric(metrics, "DurationMilliseconds", duration);
|
|
5527
|
+
try {
|
|
5528
|
+
await emitMetrics(client, metrics);
|
|
5529
|
+
await client.close();
|
|
5530
|
+
} catch {
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5535
|
+
// src/client/modules/compute/app/deploy.ts
|
|
5329
5536
|
function validateDeployOptions(options) {
|
|
5330
5537
|
if (!options.privateKey) {
|
|
5331
5538
|
throw new Error("privateKey is required for deployment");
|
|
@@ -5352,84 +5559,95 @@ function validateDeployOptions(options) {
|
|
|
5352
5559
|
validateLogVisibility(options.logVisibility);
|
|
5353
5560
|
}
|
|
5354
5561
|
async function deploy(options, logger = defaultLogger) {
|
|
5355
|
-
|
|
5356
|
-
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5357
|
-
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5358
|
-
logger.debug("Performing preflight checks...");
|
|
5359
|
-
const preflightCtx = await doPreflightChecks(
|
|
5360
|
-
{
|
|
5361
|
-
privateKey: options.privateKey,
|
|
5362
|
-
rpcUrl: options.rpcUrl,
|
|
5363
|
-
environment: options.environment
|
|
5364
|
-
},
|
|
5365
|
-
logger
|
|
5366
|
-
);
|
|
5367
|
-
logger.debug("Checking quota availability...");
|
|
5368
|
-
await checkQuotaAvailable(preflightCtx);
|
|
5369
|
-
logger.debug("Checking Docker...");
|
|
5370
|
-
await ensureDockerIsRunning();
|
|
5371
|
-
const dockerfilePath = options.dockerfilePath || "";
|
|
5372
|
-
const imageRef = options.imageRef || "";
|
|
5373
|
-
const appName = options.appName;
|
|
5374
|
-
const envFilePath = options.envFilePath || "";
|
|
5375
|
-
const instanceType = options.instanceType;
|
|
5376
|
-
const salt = generateRandomSalt();
|
|
5377
|
-
logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
|
|
5378
|
-
logger.debug("Calculating app ID...");
|
|
5379
|
-
const appIDToBeDeployed = await calculateAppID(
|
|
5380
|
-
preflightCtx.privateKey,
|
|
5381
|
-
options.rpcUrl || preflightCtx.rpcUrl,
|
|
5382
|
-
preflightCtx.environmentConfig,
|
|
5383
|
-
salt
|
|
5384
|
-
);
|
|
5385
|
-
logger.info(``);
|
|
5386
|
-
logger.info(`App ID: ${appIDToBeDeployed}`);
|
|
5387
|
-
logger.info(``);
|
|
5388
|
-
logger.info("Preparing release...");
|
|
5389
|
-
const { release, finalImageRef } = await prepareRelease(
|
|
5390
|
-
{
|
|
5391
|
-
dockerfilePath,
|
|
5392
|
-
imageRef,
|
|
5393
|
-
envFilePath,
|
|
5394
|
-
logRedirect,
|
|
5395
|
-
resourceUsageAllow,
|
|
5396
|
-
instanceType,
|
|
5397
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5398
|
-
appId: appIDToBeDeployed
|
|
5399
|
-
},
|
|
5400
|
-
logger
|
|
5401
|
-
);
|
|
5402
|
-
logger.info("Deploying on-chain...");
|
|
5403
|
-
const deployResult = await deployApp(
|
|
5404
|
-
{
|
|
5405
|
-
privateKey: preflightCtx.privateKey,
|
|
5406
|
-
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5407
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5408
|
-
salt,
|
|
5409
|
-
release,
|
|
5410
|
-
publicLogs,
|
|
5411
|
-
imageRef: finalImageRef,
|
|
5412
|
-
gas: options.gas
|
|
5413
|
-
},
|
|
5414
|
-
logger
|
|
5415
|
-
);
|
|
5416
|
-
logger.info("Waiting for app to start...");
|
|
5417
|
-
const ipAddress = await watchUntilRunning(
|
|
5562
|
+
return withSDKTelemetry(
|
|
5418
5563
|
{
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5564
|
+
functionName: "deploy",
|
|
5565
|
+
skipTelemetry: options.skipTelemetry,
|
|
5566
|
+
properties: {
|
|
5567
|
+
environment: options.environment || "sepolia"
|
|
5568
|
+
}
|
|
5423
5569
|
},
|
|
5424
|
-
|
|
5570
|
+
async () => {
|
|
5571
|
+
validateDeployOptions(options);
|
|
5572
|
+
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5573
|
+
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5574
|
+
logger.debug("Performing preflight checks...");
|
|
5575
|
+
const preflightCtx = await doPreflightChecks(
|
|
5576
|
+
{
|
|
5577
|
+
privateKey: options.privateKey,
|
|
5578
|
+
rpcUrl: options.rpcUrl,
|
|
5579
|
+
environment: options.environment
|
|
5580
|
+
},
|
|
5581
|
+
logger
|
|
5582
|
+
);
|
|
5583
|
+
logger.debug("Checking quota availability...");
|
|
5584
|
+
await checkQuotaAvailable(preflightCtx);
|
|
5585
|
+
logger.debug("Checking Docker...");
|
|
5586
|
+
await ensureDockerIsRunning();
|
|
5587
|
+
const dockerfilePath = options.dockerfilePath || "";
|
|
5588
|
+
const imageRef = options.imageRef || "";
|
|
5589
|
+
const appName = options.appName;
|
|
5590
|
+
const envFilePath = options.envFilePath || "";
|
|
5591
|
+
const instanceType = options.instanceType;
|
|
5592
|
+
const salt = generateRandomSalt();
|
|
5593
|
+
logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
|
|
5594
|
+
logger.debug("Calculating app ID...");
|
|
5595
|
+
const appIDToBeDeployed = await calculateAppID(
|
|
5596
|
+
preflightCtx.privateKey,
|
|
5597
|
+
options.rpcUrl || preflightCtx.rpcUrl,
|
|
5598
|
+
preflightCtx.environmentConfig,
|
|
5599
|
+
salt
|
|
5600
|
+
);
|
|
5601
|
+
logger.info(``);
|
|
5602
|
+
logger.info(`App ID: ${appIDToBeDeployed}`);
|
|
5603
|
+
logger.info(``);
|
|
5604
|
+
logger.info("Preparing release...");
|
|
5605
|
+
const { release, finalImageRef } = await prepareRelease(
|
|
5606
|
+
{
|
|
5607
|
+
dockerfilePath,
|
|
5608
|
+
imageRef,
|
|
5609
|
+
envFilePath,
|
|
5610
|
+
logRedirect,
|
|
5611
|
+
resourceUsageAllow,
|
|
5612
|
+
instanceType,
|
|
5613
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5614
|
+
appId: appIDToBeDeployed
|
|
5615
|
+
},
|
|
5616
|
+
logger
|
|
5617
|
+
);
|
|
5618
|
+
logger.info("Deploying on-chain...");
|
|
5619
|
+
const deployResult = await deployApp(
|
|
5620
|
+
{
|
|
5621
|
+
privateKey: preflightCtx.privateKey,
|
|
5622
|
+
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5623
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5624
|
+
salt,
|
|
5625
|
+
release,
|
|
5626
|
+
publicLogs,
|
|
5627
|
+
imageRef: finalImageRef,
|
|
5628
|
+
gas: options.gas
|
|
5629
|
+
},
|
|
5630
|
+
logger
|
|
5631
|
+
);
|
|
5632
|
+
logger.info("Waiting for app to start...");
|
|
5633
|
+
const ipAddress = await watchUntilRunning(
|
|
5634
|
+
{
|
|
5635
|
+
privateKey: preflightCtx.privateKey,
|
|
5636
|
+
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5637
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5638
|
+
appId: deployResult.appId
|
|
5639
|
+
},
|
|
5640
|
+
logger
|
|
5641
|
+
);
|
|
5642
|
+
return {
|
|
5643
|
+
appId: deployResult.appId,
|
|
5644
|
+
txHash: deployResult.txHash,
|
|
5645
|
+
appName,
|
|
5646
|
+
imageRef: finalImageRef,
|
|
5647
|
+
ipAddress
|
|
5648
|
+
};
|
|
5649
|
+
}
|
|
5425
5650
|
);
|
|
5426
|
-
return {
|
|
5427
|
-
appId: deployResult.appId,
|
|
5428
|
-
txHash: deployResult.txHash,
|
|
5429
|
-
appName,
|
|
5430
|
-
imageRef: finalImageRef,
|
|
5431
|
-
ipAddress
|
|
5432
|
-
};
|
|
5433
5651
|
}
|
|
5434
5652
|
async function checkQuotaAvailable(preflightCtx) {
|
|
5435
5653
|
const rpcUrl = preflightCtx.rpcUrl;
|
|
@@ -5464,107 +5682,137 @@ function generateRandomSalt() {
|
|
|
5464
5682
|
return salt;
|
|
5465
5683
|
}
|
|
5466
5684
|
async function prepareDeploy(options, logger = defaultLogger) {
|
|
5467
|
-
|
|
5468
|
-
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5469
|
-
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5470
|
-
logger.debug("Performing preflight checks...");
|
|
5471
|
-
const preflightCtx = await doPreflightChecks(
|
|
5472
|
-
{
|
|
5473
|
-
privateKey: options.privateKey,
|
|
5474
|
-
rpcUrl: options.rpcUrl,
|
|
5475
|
-
environment: options.environment
|
|
5476
|
-
},
|
|
5477
|
-
logger
|
|
5478
|
-
);
|
|
5479
|
-
logger.debug("Checking quota availability...");
|
|
5480
|
-
await checkQuotaAvailable(preflightCtx);
|
|
5481
|
-
logger.debug("Checking Docker...");
|
|
5482
|
-
await ensureDockerIsRunning();
|
|
5483
|
-
const dockerfilePath = options.dockerfilePath || "";
|
|
5484
|
-
const imageRef = options.imageRef || "";
|
|
5485
|
-
const appName = options.appName;
|
|
5486
|
-
const envFilePath = options.envFilePath || "";
|
|
5487
|
-
const instanceType = options.instanceType;
|
|
5488
|
-
const salt = generateRandomSalt();
|
|
5489
|
-
logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
|
|
5490
|
-
logger.debug("Calculating app ID...");
|
|
5491
|
-
const appIDToBeDeployed = await calculateAppID(
|
|
5492
|
-
preflightCtx.privateKey,
|
|
5493
|
-
options.rpcUrl || preflightCtx.rpcUrl,
|
|
5494
|
-
preflightCtx.environmentConfig,
|
|
5495
|
-
salt
|
|
5496
|
-
);
|
|
5497
|
-
logger.info(``);
|
|
5498
|
-
logger.info(`App ID: ${appIDToBeDeployed}`);
|
|
5499
|
-
logger.info(``);
|
|
5500
|
-
logger.info("Preparing release...");
|
|
5501
|
-
const { release, finalImageRef } = await prepareRelease(
|
|
5685
|
+
return withSDKTelemetry(
|
|
5502
5686
|
{
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
instanceType,
|
|
5509
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5510
|
-
appId: appIDToBeDeployed
|
|
5687
|
+
functionName: "prepareDeploy",
|
|
5688
|
+
skipTelemetry: options.skipTelemetry,
|
|
5689
|
+
properties: {
|
|
5690
|
+
environment: options.environment || "sepolia"
|
|
5691
|
+
}
|
|
5511
5692
|
},
|
|
5512
|
-
|
|
5693
|
+
async () => {
|
|
5694
|
+
validateDeployOptions(options);
|
|
5695
|
+
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5696
|
+
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5697
|
+
logger.debug("Performing preflight checks...");
|
|
5698
|
+
const preflightCtx = await doPreflightChecks(
|
|
5699
|
+
{
|
|
5700
|
+
privateKey: options.privateKey,
|
|
5701
|
+
rpcUrl: options.rpcUrl,
|
|
5702
|
+
environment: options.environment
|
|
5703
|
+
},
|
|
5704
|
+
logger
|
|
5705
|
+
);
|
|
5706
|
+
logger.debug("Checking quota availability...");
|
|
5707
|
+
await checkQuotaAvailable(preflightCtx);
|
|
5708
|
+
logger.debug("Checking Docker...");
|
|
5709
|
+
await ensureDockerIsRunning();
|
|
5710
|
+
const dockerfilePath = options.dockerfilePath || "";
|
|
5711
|
+
const imageRef = options.imageRef || "";
|
|
5712
|
+
const appName = options.appName;
|
|
5713
|
+
const envFilePath = options.envFilePath || "";
|
|
5714
|
+
const instanceType = options.instanceType;
|
|
5715
|
+
const salt = generateRandomSalt();
|
|
5716
|
+
logger.debug(`Generated salt: ${Buffer.from(salt).toString("hex")}`);
|
|
5717
|
+
logger.debug("Calculating app ID...");
|
|
5718
|
+
const appIDToBeDeployed = await calculateAppID(
|
|
5719
|
+
preflightCtx.privateKey,
|
|
5720
|
+
options.rpcUrl || preflightCtx.rpcUrl,
|
|
5721
|
+
preflightCtx.environmentConfig,
|
|
5722
|
+
salt
|
|
5723
|
+
);
|
|
5724
|
+
logger.info(``);
|
|
5725
|
+
logger.info(`App ID: ${appIDToBeDeployed}`);
|
|
5726
|
+
logger.info(``);
|
|
5727
|
+
logger.info("Preparing release...");
|
|
5728
|
+
const { release, finalImageRef } = await prepareRelease(
|
|
5729
|
+
{
|
|
5730
|
+
dockerfilePath,
|
|
5731
|
+
imageRef,
|
|
5732
|
+
envFilePath,
|
|
5733
|
+
logRedirect,
|
|
5734
|
+
resourceUsageAllow,
|
|
5735
|
+
instanceType,
|
|
5736
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5737
|
+
appId: appIDToBeDeployed
|
|
5738
|
+
},
|
|
5739
|
+
logger
|
|
5740
|
+
);
|
|
5741
|
+
logger.debug("Preparing deploy batch...");
|
|
5742
|
+
const batch = await prepareDeployBatch(
|
|
5743
|
+
{
|
|
5744
|
+
privateKey: preflightCtx.privateKey,
|
|
5745
|
+
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5746
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5747
|
+
salt,
|
|
5748
|
+
release,
|
|
5749
|
+
publicLogs
|
|
5750
|
+
},
|
|
5751
|
+
logger
|
|
5752
|
+
);
|
|
5753
|
+
logger.debug("Estimating gas...");
|
|
5754
|
+
const gasEstimate = await estimateBatchGas({
|
|
5755
|
+
publicClient: batch.publicClient,
|
|
5756
|
+
environmentConfig: batch.environmentConfig,
|
|
5757
|
+
executions: batch.executions
|
|
5758
|
+
});
|
|
5759
|
+
return {
|
|
5760
|
+
prepared: {
|
|
5761
|
+
batch,
|
|
5762
|
+
appName,
|
|
5763
|
+
imageRef: finalImageRef,
|
|
5764
|
+
preflightCtx: {
|
|
5765
|
+
privateKey: preflightCtx.privateKey,
|
|
5766
|
+
rpcUrl: preflightCtx.rpcUrl,
|
|
5767
|
+
environmentConfig: preflightCtx.environmentConfig
|
|
5768
|
+
}
|
|
5769
|
+
},
|
|
5770
|
+
gasEstimate
|
|
5771
|
+
};
|
|
5772
|
+
}
|
|
5513
5773
|
);
|
|
5514
|
-
|
|
5515
|
-
|
|
5774
|
+
}
|
|
5775
|
+
async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetry) {
|
|
5776
|
+
return withSDKTelemetry(
|
|
5516
5777
|
{
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5520
|
-
salt,
|
|
5521
|
-
release,
|
|
5522
|
-
publicLogs
|
|
5778
|
+
functionName: "executeDeploy",
|
|
5779
|
+
skipTelemetry
|
|
5523
5780
|
},
|
|
5524
|
-
|
|
5781
|
+
async () => {
|
|
5782
|
+
logger.info("Deploying on-chain...");
|
|
5783
|
+
const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
|
|
5784
|
+
return {
|
|
5785
|
+
appId,
|
|
5786
|
+
txHash,
|
|
5787
|
+
appName: prepared.appName,
|
|
5788
|
+
imageRef: prepared.imageRef
|
|
5789
|
+
};
|
|
5790
|
+
}
|
|
5525
5791
|
);
|
|
5526
|
-
logger.debug("Estimating gas...");
|
|
5527
|
-
const gasEstimate = await estimateBatchGas({
|
|
5528
|
-
publicClient: batch.publicClient,
|
|
5529
|
-
environmentConfig: batch.environmentConfig,
|
|
5530
|
-
executions: batch.executions
|
|
5531
|
-
});
|
|
5532
|
-
return {
|
|
5533
|
-
prepared: {
|
|
5534
|
-
batch,
|
|
5535
|
-
appName,
|
|
5536
|
-
imageRef: finalImageRef,
|
|
5537
|
-
preflightCtx: {
|
|
5538
|
-
privateKey: preflightCtx.privateKey,
|
|
5539
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
5540
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
5541
|
-
}
|
|
5542
|
-
},
|
|
5543
|
-
gasEstimate
|
|
5544
|
-
};
|
|
5545
|
-
}
|
|
5546
|
-
async function executeDeploy(prepared, gas, logger = defaultLogger) {
|
|
5547
|
-
logger.info("Deploying on-chain...");
|
|
5548
|
-
const { appId, txHash } = await executeDeployBatch(prepared.batch, gas, logger);
|
|
5549
|
-
return {
|
|
5550
|
-
appId,
|
|
5551
|
-
txHash,
|
|
5552
|
-
appName: prepared.appName,
|
|
5553
|
-
imageRef: prepared.imageRef
|
|
5554
|
-
};
|
|
5555
5792
|
}
|
|
5556
|
-
async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId) {
|
|
5557
|
-
|
|
5558
|
-
logger.info("Waiting for app to start...");
|
|
5559
|
-
return watchUntilRunning(
|
|
5793
|
+
async function watchDeployment(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId, skipTelemetry) {
|
|
5794
|
+
return withSDKTelemetry(
|
|
5560
5795
|
{
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5796
|
+
functionName: "watchDeployment",
|
|
5797
|
+
skipTelemetry,
|
|
5798
|
+
properties: {
|
|
5799
|
+
environment
|
|
5800
|
+
}
|
|
5566
5801
|
},
|
|
5567
|
-
|
|
5802
|
+
async () => {
|
|
5803
|
+
const environmentConfig = getEnvironmentConfig(environment);
|
|
5804
|
+
logger.info("Waiting for app to start...");
|
|
5805
|
+
return watchUntilRunning(
|
|
5806
|
+
{
|
|
5807
|
+
privateKey,
|
|
5808
|
+
rpcUrl,
|
|
5809
|
+
environmentConfig,
|
|
5810
|
+
appId,
|
|
5811
|
+
clientId
|
|
5812
|
+
},
|
|
5813
|
+
logger
|
|
5814
|
+
);
|
|
5815
|
+
}
|
|
5568
5816
|
);
|
|
5569
5817
|
}
|
|
5570
5818
|
|
|
@@ -5593,7 +5841,7 @@ async function checkAppLogPermission(preflightCtx, appAddress, logger) {
|
|
|
5593
5841
|
}
|
|
5594
5842
|
}
|
|
5595
5843
|
|
|
5596
|
-
// src/client/modules/app/upgrade.ts
|
|
5844
|
+
// src/client/modules/compute/app/upgrade.ts
|
|
5597
5845
|
function validateUpgradeOptions(options) {
|
|
5598
5846
|
if (!options.privateKey) {
|
|
5599
5847
|
throw new Error("privateKey is required for upgrade");
|
|
@@ -5621,163 +5869,204 @@ function validateUpgradeOptions(options) {
|
|
|
5621
5869
|
return resolvedAppID;
|
|
5622
5870
|
}
|
|
5623
5871
|
async function upgrade(options, logger = defaultLogger) {
|
|
5624
|
-
|
|
5625
|
-
const preflightCtx = await doPreflightChecks(
|
|
5626
|
-
{
|
|
5627
|
-
privateKey: options.privateKey,
|
|
5628
|
-
rpcUrl: options.rpcUrl,
|
|
5629
|
-
environment: options.environment
|
|
5630
|
-
},
|
|
5631
|
-
logger
|
|
5632
|
-
);
|
|
5633
|
-
const appID = validateUpgradeOptions(options);
|
|
5634
|
-
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5635
|
-
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5636
|
-
logger.debug("Checking Docker...");
|
|
5637
|
-
await ensureDockerIsRunning();
|
|
5638
|
-
const dockerfilePath = options.dockerfilePath || "";
|
|
5639
|
-
const imageRef = options.imageRef || "";
|
|
5640
|
-
const envFilePath = options.envFilePath || "";
|
|
5641
|
-
const instanceType = options.instanceType;
|
|
5642
|
-
logger.info("Preparing release...");
|
|
5643
|
-
const { release, finalImageRef } = await prepareRelease(
|
|
5872
|
+
return withSDKTelemetry(
|
|
5644
5873
|
{
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
instanceType,
|
|
5651
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5652
|
-
appId: appID
|
|
5653
|
-
},
|
|
5654
|
-
logger
|
|
5655
|
-
);
|
|
5656
|
-
logger.debug("Checking current log permission state...");
|
|
5657
|
-
const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
|
|
5658
|
-
const needsPermissionChange = currentlyPublic !== publicLogs;
|
|
5659
|
-
logger.info("Upgrading on-chain...");
|
|
5660
|
-
const txHash = await upgradeApp(
|
|
5661
|
-
{
|
|
5662
|
-
privateKey: preflightCtx.privateKey,
|
|
5663
|
-
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5664
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5665
|
-
appId: appID,
|
|
5666
|
-
release,
|
|
5667
|
-
publicLogs,
|
|
5668
|
-
needsPermissionChange,
|
|
5669
|
-
imageRef: finalImageRef,
|
|
5670
|
-
gas: options.gas
|
|
5671
|
-
},
|
|
5672
|
-
logger
|
|
5673
|
-
);
|
|
5674
|
-
logger.info("Waiting for upgrade to complete...");
|
|
5675
|
-
await watchUntilUpgradeComplete(
|
|
5676
|
-
{
|
|
5677
|
-
privateKey: preflightCtx.privateKey,
|
|
5678
|
-
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5679
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5680
|
-
appId: appID
|
|
5874
|
+
functionName: "upgrade",
|
|
5875
|
+
skipTelemetry: options.skipTelemetry,
|
|
5876
|
+
properties: {
|
|
5877
|
+
environment: options.environment || "sepolia"
|
|
5878
|
+
}
|
|
5681
5879
|
},
|
|
5682
|
-
|
|
5880
|
+
async () => {
|
|
5881
|
+
logger.debug("Performing preflight checks...");
|
|
5882
|
+
const preflightCtx = await doPreflightChecks(
|
|
5883
|
+
{
|
|
5884
|
+
privateKey: options.privateKey,
|
|
5885
|
+
rpcUrl: options.rpcUrl,
|
|
5886
|
+
environment: options.environment
|
|
5887
|
+
},
|
|
5888
|
+
logger
|
|
5889
|
+
);
|
|
5890
|
+
const appID = validateUpgradeOptions(options);
|
|
5891
|
+
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5892
|
+
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5893
|
+
logger.debug("Checking Docker...");
|
|
5894
|
+
await ensureDockerIsRunning();
|
|
5895
|
+
const dockerfilePath = options.dockerfilePath || "";
|
|
5896
|
+
const imageRef = options.imageRef || "";
|
|
5897
|
+
const envFilePath = options.envFilePath || "";
|
|
5898
|
+
const instanceType = options.instanceType;
|
|
5899
|
+
logger.info("Preparing release...");
|
|
5900
|
+
const { release, finalImageRef } = await prepareRelease(
|
|
5901
|
+
{
|
|
5902
|
+
dockerfilePath,
|
|
5903
|
+
imageRef,
|
|
5904
|
+
envFilePath,
|
|
5905
|
+
logRedirect,
|
|
5906
|
+
resourceUsageAllow,
|
|
5907
|
+
instanceType,
|
|
5908
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5909
|
+
appId: appID
|
|
5910
|
+
},
|
|
5911
|
+
logger
|
|
5912
|
+
);
|
|
5913
|
+
logger.debug("Checking current log permission state...");
|
|
5914
|
+
const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
|
|
5915
|
+
const needsPermissionChange = currentlyPublic !== publicLogs;
|
|
5916
|
+
logger.info("Upgrading on-chain...");
|
|
5917
|
+
const txHash = await upgradeApp(
|
|
5918
|
+
{
|
|
5919
|
+
privateKey: preflightCtx.privateKey,
|
|
5920
|
+
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5921
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5922
|
+
appId: appID,
|
|
5923
|
+
release,
|
|
5924
|
+
publicLogs,
|
|
5925
|
+
needsPermissionChange,
|
|
5926
|
+
imageRef: finalImageRef,
|
|
5927
|
+
gas: options.gas
|
|
5928
|
+
},
|
|
5929
|
+
logger
|
|
5930
|
+
);
|
|
5931
|
+
logger.info("Waiting for upgrade to complete...");
|
|
5932
|
+
await watchUntilUpgradeComplete(
|
|
5933
|
+
{
|
|
5934
|
+
privateKey: preflightCtx.privateKey,
|
|
5935
|
+
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5936
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5937
|
+
appId: appID
|
|
5938
|
+
},
|
|
5939
|
+
logger
|
|
5940
|
+
);
|
|
5941
|
+
return {
|
|
5942
|
+
appId: appID,
|
|
5943
|
+
imageRef: finalImageRef,
|
|
5944
|
+
txHash
|
|
5945
|
+
};
|
|
5946
|
+
}
|
|
5683
5947
|
);
|
|
5684
|
-
return {
|
|
5685
|
-
appId: appID,
|
|
5686
|
-
imageRef: finalImageRef,
|
|
5687
|
-
txHash
|
|
5688
|
-
};
|
|
5689
5948
|
}
|
|
5690
5949
|
async function prepareUpgrade(options, logger = defaultLogger) {
|
|
5691
|
-
|
|
5692
|
-
const preflightCtx = await doPreflightChecks(
|
|
5950
|
+
return withSDKTelemetry(
|
|
5693
5951
|
{
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5952
|
+
functionName: "prepareUpgrade",
|
|
5953
|
+
skipTelemetry: options.skipTelemetry,
|
|
5954
|
+
properties: {
|
|
5955
|
+
environment: options.environment || "sepolia"
|
|
5956
|
+
}
|
|
5697
5957
|
},
|
|
5698
|
-
|
|
5958
|
+
async () => {
|
|
5959
|
+
logger.debug("Performing preflight checks...");
|
|
5960
|
+
const preflightCtx = await doPreflightChecks(
|
|
5961
|
+
{
|
|
5962
|
+
privateKey: options.privateKey,
|
|
5963
|
+
rpcUrl: options.rpcUrl,
|
|
5964
|
+
environment: options.environment
|
|
5965
|
+
},
|
|
5966
|
+
logger
|
|
5967
|
+
);
|
|
5968
|
+
const appID = validateUpgradeOptions(options);
|
|
5969
|
+
const { logRedirect, publicLogs } = validateLogVisibility(options.logVisibility);
|
|
5970
|
+
const resourceUsageAllow = validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
5971
|
+
logger.debug("Checking Docker...");
|
|
5972
|
+
await ensureDockerIsRunning();
|
|
5973
|
+
const dockerfilePath = options.dockerfilePath || "";
|
|
5974
|
+
const imageRef = options.imageRef || "";
|
|
5975
|
+
const envFilePath = options.envFilePath || "";
|
|
5976
|
+
const instanceType = options.instanceType;
|
|
5977
|
+
logger.info("Preparing release...");
|
|
5978
|
+
const { release, finalImageRef } = await prepareRelease(
|
|
5979
|
+
{
|
|
5980
|
+
dockerfilePath,
|
|
5981
|
+
imageRef,
|
|
5982
|
+
envFilePath,
|
|
5983
|
+
logRedirect,
|
|
5984
|
+
resourceUsageAllow,
|
|
5985
|
+
instanceType,
|
|
5986
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5987
|
+
appId: appID
|
|
5988
|
+
},
|
|
5989
|
+
logger
|
|
5990
|
+
);
|
|
5991
|
+
logger.debug("Checking current log permission state...");
|
|
5992
|
+
const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
|
|
5993
|
+
const needsPermissionChange = currentlyPublic !== publicLogs;
|
|
5994
|
+
logger.debug("Preparing upgrade batch...");
|
|
5995
|
+
const batch = await prepareUpgradeBatch({
|
|
5996
|
+
privateKey: preflightCtx.privateKey,
|
|
5997
|
+
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5998
|
+
environmentConfig: preflightCtx.environmentConfig,
|
|
5999
|
+
appId: appID,
|
|
6000
|
+
release,
|
|
6001
|
+
publicLogs,
|
|
6002
|
+
needsPermissionChange
|
|
6003
|
+
});
|
|
6004
|
+
logger.debug("Estimating gas...");
|
|
6005
|
+
const gasEstimate = await estimateBatchGas({
|
|
6006
|
+
publicClient: batch.publicClient,
|
|
6007
|
+
environmentConfig: batch.environmentConfig,
|
|
6008
|
+
executions: batch.executions
|
|
6009
|
+
});
|
|
6010
|
+
return {
|
|
6011
|
+
prepared: {
|
|
6012
|
+
batch,
|
|
6013
|
+
appId: appID,
|
|
6014
|
+
imageRef: finalImageRef,
|
|
6015
|
+
preflightCtx: {
|
|
6016
|
+
privateKey: preflightCtx.privateKey,
|
|
6017
|
+
rpcUrl: preflightCtx.rpcUrl,
|
|
6018
|
+
environmentConfig: preflightCtx.environmentConfig
|
|
6019
|
+
}
|
|
6020
|
+
},
|
|
6021
|
+
gasEstimate
|
|
6022
|
+
};
|
|
6023
|
+
}
|
|
5699
6024
|
);
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
logger.debug("Checking Docker...");
|
|
5704
|
-
await ensureDockerIsRunning();
|
|
5705
|
-
const dockerfilePath = options.dockerfilePath || "";
|
|
5706
|
-
const imageRef = options.imageRef || "";
|
|
5707
|
-
const envFilePath = options.envFilePath || "";
|
|
5708
|
-
const instanceType = options.instanceType;
|
|
5709
|
-
logger.info("Preparing release...");
|
|
5710
|
-
const { release, finalImageRef } = await prepareRelease(
|
|
6025
|
+
}
|
|
6026
|
+
async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemetry) {
|
|
6027
|
+
return withSDKTelemetry(
|
|
5711
6028
|
{
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
envFilePath,
|
|
5715
|
-
logRedirect,
|
|
5716
|
-
resourceUsageAllow,
|
|
5717
|
-
instanceType,
|
|
5718
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5719
|
-
appId: appID
|
|
6029
|
+
functionName: "executeUpgrade",
|
|
6030
|
+
skipTelemetry
|
|
5720
6031
|
},
|
|
5721
|
-
|
|
6032
|
+
async () => {
|
|
6033
|
+
logger.info("Upgrading on-chain...");
|
|
6034
|
+
const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
|
|
6035
|
+
return {
|
|
6036
|
+
appId: prepared.appId,
|
|
6037
|
+
imageRef: prepared.imageRef,
|
|
6038
|
+
txHash
|
|
6039
|
+
};
|
|
6040
|
+
}
|
|
5722
6041
|
);
|
|
5723
|
-
logger.debug("Checking current log permission state...");
|
|
5724
|
-
const currentlyPublic = await checkAppLogPermission(preflightCtx, appID, logger);
|
|
5725
|
-
const needsPermissionChange = currentlyPublic !== publicLogs;
|
|
5726
|
-
logger.debug("Preparing upgrade batch...");
|
|
5727
|
-
const batch = await prepareUpgradeBatch({
|
|
5728
|
-
privateKey: preflightCtx.privateKey,
|
|
5729
|
-
rpcUrl: options.rpcUrl || preflightCtx.rpcUrl,
|
|
5730
|
-
environmentConfig: preflightCtx.environmentConfig,
|
|
5731
|
-
appId: appID,
|
|
5732
|
-
release,
|
|
5733
|
-
publicLogs,
|
|
5734
|
-
needsPermissionChange
|
|
5735
|
-
});
|
|
5736
|
-
logger.debug("Estimating gas...");
|
|
5737
|
-
const gasEstimate = await estimateBatchGas({
|
|
5738
|
-
publicClient: batch.publicClient,
|
|
5739
|
-
environmentConfig: batch.environmentConfig,
|
|
5740
|
-
executions: batch.executions
|
|
5741
|
-
});
|
|
5742
|
-
return {
|
|
5743
|
-
prepared: {
|
|
5744
|
-
batch,
|
|
5745
|
-
appId: appID,
|
|
5746
|
-
imageRef: finalImageRef,
|
|
5747
|
-
preflightCtx: {
|
|
5748
|
-
privateKey: preflightCtx.privateKey,
|
|
5749
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
5750
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
5751
|
-
}
|
|
5752
|
-
},
|
|
5753
|
-
gasEstimate
|
|
5754
|
-
};
|
|
5755
6042
|
}
|
|
5756
|
-
async function
|
|
5757
|
-
|
|
5758
|
-
const txHash = await executeUpgradeBatch(prepared.batch, gas, logger);
|
|
5759
|
-
return {
|
|
5760
|
-
appId: prepared.appId,
|
|
5761
|
-
imageRef: prepared.imageRef,
|
|
5762
|
-
txHash
|
|
5763
|
-
};
|
|
5764
|
-
}
|
|
5765
|
-
async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId) {
|
|
5766
|
-
const environmentConfig = getEnvironmentConfig(environment);
|
|
5767
|
-
logger.info("Waiting for upgrade to complete...");
|
|
5768
|
-
await watchUntilUpgradeComplete(
|
|
6043
|
+
async function watchUpgrade(appId, privateKey, rpcUrl, environment, logger = defaultLogger, clientId, skipTelemetry) {
|
|
6044
|
+
return withSDKTelemetry(
|
|
5769
6045
|
{
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
6046
|
+
functionName: "watchUpgrade",
|
|
6047
|
+
skipTelemetry,
|
|
6048
|
+
properties: {
|
|
6049
|
+
environment
|
|
6050
|
+
}
|
|
5775
6051
|
},
|
|
5776
|
-
|
|
6052
|
+
async () => {
|
|
6053
|
+
const environmentConfig = getEnvironmentConfig(environment);
|
|
6054
|
+
logger.info("Waiting for upgrade to complete...");
|
|
6055
|
+
await watchUntilUpgradeComplete(
|
|
6056
|
+
{
|
|
6057
|
+
privateKey,
|
|
6058
|
+
rpcUrl,
|
|
6059
|
+
environmentConfig,
|
|
6060
|
+
appId,
|
|
6061
|
+
clientId
|
|
6062
|
+
},
|
|
6063
|
+
logger
|
|
6064
|
+
);
|
|
6065
|
+
}
|
|
5777
6066
|
);
|
|
5778
6067
|
}
|
|
5779
6068
|
|
|
5780
|
-
// src/client/modules/app/create.ts
|
|
6069
|
+
// src/client/modules/compute/app/create.ts
|
|
5781
6070
|
var fs7 = __toESM(require("fs"), 1);
|
|
5782
6071
|
var path7 = __toESM(require("path"), 1);
|
|
5783
6072
|
|
|
@@ -5870,7 +6159,7 @@ function getCategoryDescriptions(catalog, language) {
|
|
|
5870
6159
|
// src/client/common/templates/git.ts
|
|
5871
6160
|
var fs5 = __toESM(require("fs"), 1);
|
|
5872
6161
|
var path5 = __toESM(require("path"), 1);
|
|
5873
|
-
var
|
|
6162
|
+
var os3 = __toESM(require("os"), 1);
|
|
5874
6163
|
var import_child_process2 = require("child_process");
|
|
5875
6164
|
var import_util4 = require("util");
|
|
5876
6165
|
var execAsync2 = (0, import_util4.promisify)(import_child_process2.exec);
|
|
@@ -5909,9 +6198,9 @@ async function fetchTemplateSubdirectory(repoURL, ref, subPath, targetDir, logge
|
|
|
5909
6198
|
}
|
|
5910
6199
|
let tempDir;
|
|
5911
6200
|
try {
|
|
5912
|
-
tempDir = fs5.mkdtempSync(path5.join(
|
|
6201
|
+
tempDir = fs5.mkdtempSync(path5.join(os3.tmpdir(), "eigenx-template-"));
|
|
5913
6202
|
} catch {
|
|
5914
|
-
const homeDir =
|
|
6203
|
+
const homeDir = os3.homedir();
|
|
5915
6204
|
const fallbackBase = path5.join(homeDir, ".eigenx", "tmp");
|
|
5916
6205
|
fs5.mkdirSync(fallbackBase, { recursive: true });
|
|
5917
6206
|
tempDir = fs5.mkdtempSync(path5.join(fallbackBase, "eigenx-template-"));
|
|
@@ -6088,7 +6377,7 @@ async function updateProjectFile(projectDir, filename, oldString, newString, log
|
|
|
6088
6377
|
fs6.writeFileSync(filePath, newContent, { mode: 420 });
|
|
6089
6378
|
}
|
|
6090
6379
|
|
|
6091
|
-
// src/client/modules/app/create.ts
|
|
6380
|
+
// src/client/modules/compute/app/create.ts
|
|
6092
6381
|
var PRIMARY_LANGUAGES = ["typescript", "golang", "rust", "python"];
|
|
6093
6382
|
function validateProjectName(name) {
|
|
6094
6383
|
if (!name) {
|
|
@@ -6129,30 +6418,41 @@ async function getAvailableTemplates(language) {
|
|
|
6129
6418
|
}));
|
|
6130
6419
|
}
|
|
6131
6420
|
async function createApp(options, logger = defaultLogger) {
|
|
6132
|
-
|
|
6133
|
-
validateLanguage(options.language || "");
|
|
6134
|
-
const cfg = await gatherProjectConfig(
|
|
6421
|
+
return withSDKTelemetry(
|
|
6135
6422
|
{
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6423
|
+
functionName: "createApp",
|
|
6424
|
+
skipTelemetry: options.skipTelemetry,
|
|
6425
|
+
properties: {
|
|
6426
|
+
language: options.language || ""
|
|
6427
|
+
}
|
|
6139
6428
|
},
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6429
|
+
async () => {
|
|
6430
|
+
validateProjectName(options.name || "");
|
|
6431
|
+
validateLanguage(options.language || "");
|
|
6432
|
+
const cfg = await gatherProjectConfig(
|
|
6433
|
+
{
|
|
6434
|
+
...options,
|
|
6435
|
+
name: options.name,
|
|
6436
|
+
language: options.language
|
|
6437
|
+
},
|
|
6438
|
+
logger
|
|
6439
|
+
);
|
|
6440
|
+
if (fs7.existsSync(cfg.name)) {
|
|
6441
|
+
throw new Error(`Directory ${cfg.name} already exists`);
|
|
6442
|
+
}
|
|
6443
|
+
fs7.mkdirSync(cfg.name, { mode: 493 });
|
|
6444
|
+
try {
|
|
6445
|
+
await populateProjectFromTemplate(cfg, options, logger);
|
|
6446
|
+
if (cfg.subPath && cfg.language && cfg.templateEntry) {
|
|
6447
|
+
await postProcessTemplate(cfg.name, cfg.language, cfg.templateEntry, logger);
|
|
6448
|
+
}
|
|
6449
|
+
logger.info(`Successfully created ${cfg.language || "project"} project: ${cfg.name}`);
|
|
6450
|
+
} catch (error) {
|
|
6451
|
+
fs7.rmSync(cfg.name, { recursive: true, force: true });
|
|
6452
|
+
throw error;
|
|
6453
|
+
}
|
|
6150
6454
|
}
|
|
6151
|
-
|
|
6152
|
-
} catch (error) {
|
|
6153
|
-
fs7.rmSync(cfg.name, { recursive: true, force: true });
|
|
6154
|
-
throw error;
|
|
6155
|
-
}
|
|
6455
|
+
);
|
|
6156
6456
|
}
|
|
6157
6457
|
async function gatherProjectConfig(options, logger) {
|
|
6158
6458
|
const cfg = {
|
|
@@ -6240,7 +6540,7 @@ async function copyDirectory2(src, dst) {
|
|
|
6240
6540
|
}
|
|
6241
6541
|
}
|
|
6242
6542
|
|
|
6243
|
-
// src/client/modules/app/logs.ts
|
|
6543
|
+
// src/client/modules/compute/app/logs.ts
|
|
6244
6544
|
var import_chalk = __toESM(require("chalk"), 1);
|
|
6245
6545
|
var AppStatusCreated = "Created";
|
|
6246
6546
|
var AppStatusDeploying = "Deploying";
|
|
@@ -6322,93 +6622,107 @@ async function watchLogs(appID, userApiClient, initialLogs) {
|
|
|
6322
6622
|
}
|
|
6323
6623
|
console.log("\nStopped watching");
|
|
6324
6624
|
}
|
|
6325
|
-
async function logs(options, logger = defaultLogger) {
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
throw new Error("RPC URL is required for authenticated requests");
|
|
6335
|
-
}
|
|
6336
|
-
const appID = validateAppID(options.appID);
|
|
6337
|
-
const formattedApp = formatAppDisplay(environmentConfig.name, appID, "");
|
|
6338
|
-
const userApiClient = new UserApiClient(
|
|
6339
|
-
environmentConfig,
|
|
6340
|
-
options.privateKey,
|
|
6341
|
-
rpcUrl,
|
|
6342
|
-
options.clientId
|
|
6343
|
-
);
|
|
6344
|
-
let logsText;
|
|
6345
|
-
let logsError = null;
|
|
6346
|
-
try {
|
|
6347
|
-
logsText = await userApiClient.getLogs(appID);
|
|
6348
|
-
} catch (err) {
|
|
6349
|
-
logsError = err;
|
|
6350
|
-
logsText = "";
|
|
6351
|
-
}
|
|
6352
|
-
const watchMode = options.watch || false;
|
|
6353
|
-
if (logsError || logsText.trim() === "") {
|
|
6354
|
-
if (watchMode) {
|
|
6355
|
-
logger.info("\nWaiting for logs to become available...");
|
|
6625
|
+
async function logs(options, logger = defaultLogger, skipTelemetry = false) {
|
|
6626
|
+
const skipTelemetryFlag = skipTelemetry || options.skipTelemetry || false;
|
|
6627
|
+
return withSDKTelemetry(
|
|
6628
|
+
{
|
|
6629
|
+
functionName: "logs",
|
|
6630
|
+
skipTelemetry: skipTelemetryFlag,
|
|
6631
|
+
properties: { environment: options.environment || "sepolia" }
|
|
6632
|
+
},
|
|
6633
|
+
async () => {
|
|
6356
6634
|
console.log();
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
const
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6635
|
+
if (!options.appID) {
|
|
6636
|
+
throw new Error("appID is required for viewing logs");
|
|
6637
|
+
}
|
|
6638
|
+
const environment = options.environment || "sepolia";
|
|
6639
|
+
const environmentConfig = getEnvironmentConfig(environment);
|
|
6640
|
+
const rpcUrl = options.rpcUrl || environmentConfig.defaultRPCURL;
|
|
6641
|
+
if (!rpcUrl) {
|
|
6642
|
+
throw new Error("RPC URL is required for authenticated requests");
|
|
6643
|
+
}
|
|
6644
|
+
const appID = validateAppID(options.appID);
|
|
6645
|
+
const formattedApp = formatAppDisplay(environmentConfig.name, appID, "");
|
|
6646
|
+
const userApiClient = new UserApiClient(
|
|
6647
|
+
environmentConfig,
|
|
6648
|
+
options.privateKey,
|
|
6649
|
+
rpcUrl,
|
|
6650
|
+
options.clientId
|
|
6651
|
+
);
|
|
6652
|
+
let logsText;
|
|
6653
|
+
let logsError = null;
|
|
6654
|
+
try {
|
|
6655
|
+
logsText = await userApiClient.getLogs(appID);
|
|
6656
|
+
} catch (err) {
|
|
6657
|
+
logsError = err;
|
|
6658
|
+
logsText = "";
|
|
6659
|
+
}
|
|
6660
|
+
const watchMode = options.watch || false;
|
|
6661
|
+
if (logsError || logsText.trim() === "") {
|
|
6662
|
+
if (watchMode) {
|
|
6663
|
+
logger.info("\nWaiting for logs to become available...");
|
|
6664
|
+
console.log();
|
|
6665
|
+
await watchLogs(appID, userApiClient, "");
|
|
6666
|
+
return;
|
|
6667
|
+
}
|
|
6668
|
+
try {
|
|
6669
|
+
const statuses = await userApiClient.getStatuses([appID]);
|
|
6670
|
+
if (statuses.length > 0) {
|
|
6671
|
+
const status = statuses[0].status;
|
|
6672
|
+
switch (status) {
|
|
6673
|
+
case AppStatusCreated:
|
|
6674
|
+
case AppStatusDeploying:
|
|
6675
|
+
logger.info(
|
|
6676
|
+
`${formattedApp} is currently being provisioned. Logs will be available once deployment is complete.`
|
|
6677
|
+
);
|
|
6678
|
+
return;
|
|
6679
|
+
case AppStatusUpgrading:
|
|
6680
|
+
logger.info(
|
|
6681
|
+
`${formattedApp} is currently upgrading. Logs will be available once upgrade is complete.`
|
|
6682
|
+
);
|
|
6683
|
+
return;
|
|
6684
|
+
case AppStatusResuming:
|
|
6685
|
+
logger.info(
|
|
6686
|
+
`${formattedApp} is currently resuming. Logs will be available shortly.`
|
|
6687
|
+
);
|
|
6688
|
+
return;
|
|
6689
|
+
case AppStatusStopping:
|
|
6690
|
+
logger.info(`${formattedApp} is currently stopping. Logs may be limited.`);
|
|
6691
|
+
return;
|
|
6692
|
+
case AppStatusStopped:
|
|
6693
|
+
case AppStatusTerminating:
|
|
6694
|
+
case AppStatusTerminated:
|
|
6695
|
+
case AppStatusSuspended:
|
|
6696
|
+
logger.info(`${formattedApp} is ${status.toLowerCase()}. Logs are not available.`);
|
|
6697
|
+
return;
|
|
6698
|
+
case AppStatusFailed:
|
|
6699
|
+
logger.info(
|
|
6700
|
+
`${formattedApp} has failed. Check the app status for more information.`
|
|
6701
|
+
);
|
|
6702
|
+
return;
|
|
6703
|
+
}
|
|
6704
|
+
}
|
|
6705
|
+
} catch {
|
|
6706
|
+
}
|
|
6707
|
+
if (logsError) {
|
|
6708
|
+
throw new Error(
|
|
6709
|
+
`Failed to get logs, you can watch for logs by calling this command with the --watch flag (or --w): ${logsError.message}`
|
|
6710
|
+
);
|
|
6391
6711
|
}
|
|
6712
|
+
throw new Error(
|
|
6713
|
+
"Failed to get logs, you can watch for logs by calling this command with the --watch flag (or --w): empty logs"
|
|
6714
|
+
);
|
|
6392
6715
|
}
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
);
|
|
6716
|
+
console.log(logsText);
|
|
6717
|
+
if (!watchMode) {
|
|
6718
|
+
return;
|
|
6719
|
+
}
|
|
6720
|
+
await watchLogs(appID, userApiClient, logsText);
|
|
6399
6721
|
}
|
|
6400
|
-
|
|
6401
|
-
"Failed to get logs, you can watch for logs by calling this command with the --watch flag (or --w): empty logs"
|
|
6402
|
-
);
|
|
6403
|
-
}
|
|
6404
|
-
console.log(logsText);
|
|
6405
|
-
if (!watchMode) {
|
|
6406
|
-
return;
|
|
6407
|
-
}
|
|
6408
|
-
await watchLogs(appID, userApiClient, logsText);
|
|
6722
|
+
);
|
|
6409
6723
|
}
|
|
6410
6724
|
|
|
6411
|
-
// src/client/modules/app/index.ts
|
|
6725
|
+
// src/client/modules/compute/app/index.ts
|
|
6412
6726
|
var CONTROLLER_ABI = (0, import_viem9.parseAbi)([
|
|
6413
6727
|
"function startApp(address appId)",
|
|
6414
6728
|
"function stopApp(address appId)",
|
|
@@ -6437,6 +6751,7 @@ function encodeTerminateAppData(appId) {
|
|
|
6437
6751
|
}
|
|
6438
6752
|
function createAppModule(ctx) {
|
|
6439
6753
|
const privateKey = addHexPrefix(ctx.privateKey);
|
|
6754
|
+
const skipTelemetry = ctx.skipTelemetry || false;
|
|
6440
6755
|
const environment = getEnvironmentConfig(ctx.environment);
|
|
6441
6756
|
const logger = getLogger(ctx.verbose);
|
|
6442
6757
|
return {
|
|
@@ -6499,74 +6814,106 @@ function createAppModule(ctx) {
|
|
|
6499
6814
|
environment: ctx.environment,
|
|
6500
6815
|
clientId: ctx.clientId
|
|
6501
6816
|
},
|
|
6502
|
-
logger
|
|
6817
|
+
logger,
|
|
6818
|
+
skipTelemetry
|
|
6819
|
+
// Skip if called from CLI
|
|
6503
6820
|
);
|
|
6504
6821
|
},
|
|
6505
6822
|
async start(appId, opts) {
|
|
6506
|
-
|
|
6507
|
-
const data = (0, import_viem9.encodeFunctionData)({
|
|
6508
|
-
abi: CONTROLLER_ABI,
|
|
6509
|
-
functionName: "startApp",
|
|
6510
|
-
args: [appId]
|
|
6511
|
-
});
|
|
6512
|
-
const tx = await sendAndWaitForTransaction(
|
|
6823
|
+
return withSDKTelemetry(
|
|
6513
6824
|
{
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
data,
|
|
6519
|
-
pendingMessage,
|
|
6520
|
-
txDescription: "StartApp",
|
|
6521
|
-
gas: opts?.gas
|
|
6825
|
+
functionName: "start",
|
|
6826
|
+
skipTelemetry,
|
|
6827
|
+
// Skip if called from CLI
|
|
6828
|
+
properties: { environment: ctx.environment }
|
|
6522
6829
|
},
|
|
6523
|
-
|
|
6830
|
+
async () => {
|
|
6831
|
+
const pendingMessage = `Starting app ${appId}...`;
|
|
6832
|
+
const data = (0, import_viem9.encodeFunctionData)({
|
|
6833
|
+
abi: CONTROLLER_ABI,
|
|
6834
|
+
functionName: "startApp",
|
|
6835
|
+
args: [appId]
|
|
6836
|
+
});
|
|
6837
|
+
const tx = await sendAndWaitForTransaction(
|
|
6838
|
+
{
|
|
6839
|
+
privateKey,
|
|
6840
|
+
rpcUrl: ctx.rpcUrl,
|
|
6841
|
+
environmentConfig: environment,
|
|
6842
|
+
to: environment.appControllerAddress,
|
|
6843
|
+
data,
|
|
6844
|
+
pendingMessage,
|
|
6845
|
+
txDescription: "StartApp",
|
|
6846
|
+
gas: opts?.gas
|
|
6847
|
+
},
|
|
6848
|
+
logger
|
|
6849
|
+
);
|
|
6850
|
+
return { tx };
|
|
6851
|
+
}
|
|
6524
6852
|
);
|
|
6525
|
-
return { tx };
|
|
6526
6853
|
},
|
|
6527
6854
|
async stop(appId, opts) {
|
|
6528
|
-
|
|
6529
|
-
const data = (0, import_viem9.encodeFunctionData)({
|
|
6530
|
-
abi: CONTROLLER_ABI,
|
|
6531
|
-
functionName: "stopApp",
|
|
6532
|
-
args: [appId]
|
|
6533
|
-
});
|
|
6534
|
-
const tx = await sendAndWaitForTransaction(
|
|
6855
|
+
return withSDKTelemetry(
|
|
6535
6856
|
{
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
data,
|
|
6541
|
-
pendingMessage,
|
|
6542
|
-
txDescription: "StopApp",
|
|
6543
|
-
gas: opts?.gas
|
|
6857
|
+
functionName: "stop",
|
|
6858
|
+
skipTelemetry,
|
|
6859
|
+
// Skip if called from CLI
|
|
6860
|
+
properties: { environment: ctx.environment }
|
|
6544
6861
|
},
|
|
6545
|
-
|
|
6862
|
+
async () => {
|
|
6863
|
+
const pendingMessage = `Stopping app ${appId}...`;
|
|
6864
|
+
const data = (0, import_viem9.encodeFunctionData)({
|
|
6865
|
+
abi: CONTROLLER_ABI,
|
|
6866
|
+
functionName: "stopApp",
|
|
6867
|
+
args: [appId]
|
|
6868
|
+
});
|
|
6869
|
+
const tx = await sendAndWaitForTransaction(
|
|
6870
|
+
{
|
|
6871
|
+
privateKey,
|
|
6872
|
+
rpcUrl: ctx.rpcUrl,
|
|
6873
|
+
environmentConfig: environment,
|
|
6874
|
+
to: environment.appControllerAddress,
|
|
6875
|
+
data,
|
|
6876
|
+
pendingMessage,
|
|
6877
|
+
txDescription: "StopApp",
|
|
6878
|
+
gas: opts?.gas
|
|
6879
|
+
},
|
|
6880
|
+
logger
|
|
6881
|
+
);
|
|
6882
|
+
return { tx };
|
|
6883
|
+
}
|
|
6546
6884
|
);
|
|
6547
|
-
return { tx };
|
|
6548
6885
|
},
|
|
6549
6886
|
async terminate(appId, opts) {
|
|
6550
|
-
|
|
6551
|
-
const data = (0, import_viem9.encodeFunctionData)({
|
|
6552
|
-
abi: CONTROLLER_ABI,
|
|
6553
|
-
functionName: "terminateApp",
|
|
6554
|
-
args: [appId]
|
|
6555
|
-
});
|
|
6556
|
-
const tx = await sendAndWaitForTransaction(
|
|
6887
|
+
return withSDKTelemetry(
|
|
6557
6888
|
{
|
|
6558
|
-
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
data,
|
|
6563
|
-
pendingMessage,
|
|
6564
|
-
txDescription: "TerminateApp",
|
|
6565
|
-
gas: opts?.gas
|
|
6889
|
+
functionName: "terminate",
|
|
6890
|
+
skipTelemetry,
|
|
6891
|
+
// Skip if called from CLI
|
|
6892
|
+
properties: { environment: ctx.environment }
|
|
6566
6893
|
},
|
|
6567
|
-
|
|
6894
|
+
async () => {
|
|
6895
|
+
const pendingMessage = `Terminating app ${appId}...`;
|
|
6896
|
+
const data = (0, import_viem9.encodeFunctionData)({
|
|
6897
|
+
abi: CONTROLLER_ABI,
|
|
6898
|
+
functionName: "terminateApp",
|
|
6899
|
+
args: [appId]
|
|
6900
|
+
});
|
|
6901
|
+
const tx = await sendAndWaitForTransaction(
|
|
6902
|
+
{
|
|
6903
|
+
privateKey,
|
|
6904
|
+
rpcUrl: ctx.rpcUrl,
|
|
6905
|
+
environmentConfig: environment,
|
|
6906
|
+
to: environment.appControllerAddress,
|
|
6907
|
+
data,
|
|
6908
|
+
pendingMessage,
|
|
6909
|
+
txDescription: "TerminateApp",
|
|
6910
|
+
gas: opts?.gas
|
|
6911
|
+
},
|
|
6912
|
+
logger
|
|
6913
|
+
);
|
|
6914
|
+
return { tx };
|
|
6915
|
+
}
|
|
6568
6916
|
);
|
|
6569
|
-
return { tx };
|
|
6570
6917
|
},
|
|
6571
6918
|
async isDelegated() {
|
|
6572
6919
|
return isDelegated({
|
|
@@ -6576,19 +6923,36 @@ function createAppModule(ctx) {
|
|
|
6576
6923
|
});
|
|
6577
6924
|
},
|
|
6578
6925
|
async undelegate() {
|
|
6579
|
-
|
|
6926
|
+
return withSDKTelemetry(
|
|
6580
6927
|
{
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
|
|
6928
|
+
functionName: "undelegate",
|
|
6929
|
+
skipTelemetry,
|
|
6930
|
+
// Skip if called from CLI
|
|
6931
|
+
properties: { environment: ctx.environment }
|
|
6584
6932
|
},
|
|
6585
|
-
|
|
6933
|
+
async () => {
|
|
6934
|
+
const tx = await undelegate(
|
|
6935
|
+
{
|
|
6936
|
+
privateKey,
|
|
6937
|
+
rpcUrl: ctx.rpcUrl,
|
|
6938
|
+
environmentConfig: environment
|
|
6939
|
+
},
|
|
6940
|
+
logger
|
|
6941
|
+
);
|
|
6942
|
+
return { tx };
|
|
6943
|
+
}
|
|
6586
6944
|
);
|
|
6587
|
-
return { tx };
|
|
6588
6945
|
}
|
|
6589
6946
|
};
|
|
6590
6947
|
}
|
|
6591
6948
|
|
|
6949
|
+
// src/client/modules/compute/index.ts
|
|
6950
|
+
function createComputeModule(config) {
|
|
6951
|
+
return {
|
|
6952
|
+
app: createAppModule(config)
|
|
6953
|
+
};
|
|
6954
|
+
}
|
|
6955
|
+
|
|
6592
6956
|
// src/client/common/utils/billingapi.ts
|
|
6593
6957
|
var import_axios2 = __toESM(require("axios"), 1);
|
|
6594
6958
|
var import_accounts5 = require("viem/accounts");
|
|
@@ -6664,63 +7028,93 @@ Please check:
|
|
|
6664
7028
|
|
|
6665
7029
|
// src/client/modules/billing/index.ts
|
|
6666
7030
|
function createBillingModule(config) {
|
|
6667
|
-
const { verbose = false } = config;
|
|
7031
|
+
const { verbose = false, skipTelemetry = false } = config;
|
|
6668
7032
|
const privateKey = addHexPrefix(config.privateKey);
|
|
6669
7033
|
const logger = getLogger(verbose);
|
|
6670
7034
|
const billingEnvConfig = getBillingEnvironmentConfig(getBuildType());
|
|
6671
7035
|
const billingApi = new BillingApiClient(billingEnvConfig, privateKey);
|
|
6672
7036
|
return {
|
|
6673
7037
|
async subscribe(opts) {
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
7038
|
+
return withSDKTelemetry(
|
|
7039
|
+
{
|
|
7040
|
+
functionName: "subscribe",
|
|
7041
|
+
skipTelemetry,
|
|
7042
|
+
// Skip if called from CLI
|
|
7043
|
+
properties: { productId: opts?.productId || "compute" }
|
|
7044
|
+
},
|
|
7045
|
+
async () => {
|
|
7046
|
+
const productId = opts?.productId || "compute";
|
|
7047
|
+
logger.debug(`Checking existing subscription for ${productId}...`);
|
|
7048
|
+
const currentStatus = await billingApi.getSubscription(productId);
|
|
7049
|
+
if (isSubscriptionActive(currentStatus.subscriptionStatus)) {
|
|
7050
|
+
logger.debug(`Subscription already active: ${currentStatus.subscriptionStatus}`);
|
|
7051
|
+
return {
|
|
7052
|
+
type: "already_active",
|
|
7053
|
+
status: currentStatus.subscriptionStatus
|
|
7054
|
+
};
|
|
7055
|
+
}
|
|
7056
|
+
if (currentStatus.subscriptionStatus === "past_due" || currentStatus.subscriptionStatus === "unpaid") {
|
|
7057
|
+
logger.debug(`Subscription has payment issue: ${currentStatus.subscriptionStatus}`);
|
|
7058
|
+
return {
|
|
7059
|
+
type: "payment_issue",
|
|
7060
|
+
status: currentStatus.subscriptionStatus,
|
|
7061
|
+
portalUrl: currentStatus.portalUrl
|
|
7062
|
+
};
|
|
7063
|
+
}
|
|
7064
|
+
logger.debug(`Creating subscription for ${productId}...`);
|
|
7065
|
+
const result = await billingApi.createSubscription(productId);
|
|
7066
|
+
logger.debug(`Checkout URL: ${result.checkoutUrl}`);
|
|
7067
|
+
return {
|
|
7068
|
+
type: "checkout_created",
|
|
7069
|
+
checkoutUrl: result.checkoutUrl
|
|
7070
|
+
};
|
|
7071
|
+
}
|
|
7072
|
+
);
|
|
6699
7073
|
},
|
|
6700
7074
|
async getStatus(opts) {
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
7075
|
+
return withSDKTelemetry(
|
|
7076
|
+
{
|
|
7077
|
+
functionName: "getStatus",
|
|
7078
|
+
skipTelemetry,
|
|
7079
|
+
// Skip if called from CLI
|
|
7080
|
+
properties: { productId: opts?.productId || "compute" }
|
|
7081
|
+
},
|
|
7082
|
+
async () => {
|
|
7083
|
+
const productId = opts?.productId || "compute";
|
|
7084
|
+
logger.debug(`Fetching subscription status for ${productId}...`);
|
|
7085
|
+
const result = await billingApi.getSubscription(productId);
|
|
7086
|
+
logger.debug(`Subscription status: ${result.subscriptionStatus}`);
|
|
7087
|
+
return result;
|
|
7088
|
+
}
|
|
7089
|
+
);
|
|
6706
7090
|
},
|
|
6707
7091
|
async cancel(opts) {
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
7092
|
+
return withSDKTelemetry(
|
|
7093
|
+
{
|
|
7094
|
+
functionName: "cancel",
|
|
7095
|
+
skipTelemetry,
|
|
7096
|
+
// Skip if called from CLI
|
|
7097
|
+
properties: { productId: opts?.productId || "compute" }
|
|
7098
|
+
},
|
|
7099
|
+
async () => {
|
|
7100
|
+
const productId = opts?.productId || "compute";
|
|
7101
|
+
logger.debug(`Checking subscription status for ${productId}...`);
|
|
7102
|
+
const currentStatus = await billingApi.getSubscription(productId);
|
|
7103
|
+
if (!isSubscriptionActive(currentStatus.subscriptionStatus)) {
|
|
7104
|
+
logger.debug(`No active subscription to cancel: ${currentStatus.subscriptionStatus}`);
|
|
7105
|
+
return {
|
|
7106
|
+
type: "no_active_subscription",
|
|
7107
|
+
status: currentStatus.subscriptionStatus
|
|
7108
|
+
};
|
|
7109
|
+
}
|
|
7110
|
+
logger.debug(`Canceling subscription for ${productId}...`);
|
|
7111
|
+
await billingApi.cancelSubscription(productId);
|
|
7112
|
+
logger.debug(`Subscription canceled successfully`);
|
|
7113
|
+
return {
|
|
7114
|
+
type: "canceled"
|
|
7115
|
+
};
|
|
7116
|
+
}
|
|
7117
|
+
);
|
|
6724
7118
|
}
|
|
6725
7119
|
};
|
|
6726
7120
|
}
|
|
@@ -7004,7 +7398,7 @@ function createECloudClient(cfg) {
|
|
|
7004
7398
|
);
|
|
7005
7399
|
}
|
|
7006
7400
|
return {
|
|
7007
|
-
|
|
7401
|
+
compute: createComputeModule({
|
|
7008
7402
|
rpcUrl,
|
|
7009
7403
|
verbose: cfg.verbose,
|
|
7010
7404
|
privateKey: cfg.privateKey,
|
|
@@ -7018,18 +7412,26 @@ function createECloudClient(cfg) {
|
|
|
7018
7412
|
}
|
|
7019
7413
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7020
7414
|
0 && (module.exports = {
|
|
7415
|
+
NoopClient,
|
|
7021
7416
|
PRIMARY_LANGUAGES,
|
|
7417
|
+
PostHogClient,
|
|
7022
7418
|
UserApiClient,
|
|
7419
|
+
addMetric,
|
|
7420
|
+
addMetricWithDimensions,
|
|
7023
7421
|
assertValidFilePath,
|
|
7024
7422
|
assertValidImageReference,
|
|
7025
7423
|
assertValidPrivateKey,
|
|
7026
7424
|
checkERC7702Delegation,
|
|
7027
7425
|
createApp,
|
|
7028
|
-
|
|
7426
|
+
createAppEnvironment,
|
|
7029
7427
|
createBillingModule,
|
|
7428
|
+
createComputeModule,
|
|
7030
7429
|
createECloudClient,
|
|
7430
|
+
createMetricsContext,
|
|
7431
|
+
createTelemetryClient,
|
|
7031
7432
|
deleteLegacyPrivateKey,
|
|
7032
7433
|
deletePrivateKey,
|
|
7434
|
+
emitMetrics,
|
|
7033
7435
|
encodeStartAppData,
|
|
7034
7436
|
encodeStopAppData,
|
|
7035
7437
|
encodeTerminateAppData,
|
|
@@ -7053,11 +7455,14 @@ function createECloudClient(cfg) {
|
|
|
7053
7455
|
getEnvironmentConfig,
|
|
7054
7456
|
getLegacyKeys,
|
|
7055
7457
|
getLegacyPrivateKey,
|
|
7458
|
+
getPostHogAPIKey,
|
|
7459
|
+
getPostHogEndpoint,
|
|
7056
7460
|
getPrivateKey,
|
|
7057
7461
|
getPrivateKeyWithSource,
|
|
7058
7462
|
getTemplate,
|
|
7059
7463
|
isEnvironmentAvailable,
|
|
7060
7464
|
isMainnet,
|
|
7465
|
+
isNoopClient,
|
|
7061
7466
|
isSubscriptionActive,
|
|
7062
7467
|
keyExists,
|
|
7063
7468
|
listStoredKeys,
|
|
@@ -7087,6 +7492,7 @@ function createECloudClient(cfg) {
|
|
|
7087
7492
|
validateUpgradeParams,
|
|
7088
7493
|
validateXURL,
|
|
7089
7494
|
watchDeployment,
|
|
7090
|
-
watchUpgrade
|
|
7495
|
+
watchUpgrade,
|
|
7496
|
+
withSDKTelemetry
|
|
7091
7497
|
});
|
|
7092
7498
|
//# sourceMappingURL=index.cjs.map
|