@layr-labs/ecloud-sdk 0.2.0-dev → 0.2.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +2 -2
- package/dist/billing.cjs +19 -0
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.d.cts +3 -2
- package/dist/billing.d.ts +3 -2
- package/dist/billing.js +2 -2
- package/dist/{chunk-34DXGQ35.js → chunk-FY7UU55U.js} +2 -2
- package/dist/chunk-FY7UU55U.js.map +1 -0
- package/dist/chunk-GB4GM4C2.js +434 -0
- package/dist/chunk-GB4GM4C2.js.map +1 -0
- package/dist/{chunk-HLH3AMQF.js → chunk-O7EU5JL7.js} +328 -123
- package/dist/chunk-O7EU5JL7.js.map +1 -0
- package/dist/{compute-B_ibIORD.d.cts → compute-CF2HOXed.d.ts} +101 -15
- package/dist/{compute-gpepEsn3.d.ts → compute-CbmjA8kJ.d.cts} +101 -15
- package/dist/compute.cjs +772 -62
- package/dist/compute.cjs.map +1 -1
- package/dist/compute.d.cts +2 -2
- package/dist/compute.d.ts +2 -2
- package/dist/compute.js +2 -2
- package/dist/{index-D-SUX3IG.d.ts → index-D2QufVB9.d.cts} +130 -6
- package/dist/{index-D-SUX3IG.d.cts → index-D2QufVB9.d.ts} +130 -6
- package/dist/index.cjs +646 -438
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -166
- package/dist/index.d.ts +52 -166
- package/dist/index.js +17 -243
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-34DXGQ35.js.map +0 -1
- package/dist/chunk-HLH3AMQF.js.map +0 -1
- package/dist/chunk-LINGJMAS.js +0 -180
- package/dist/chunk-LINGJMAS.js.map +0 -1
|
@@ -17,17 +17,10 @@ import {
|
|
|
17
17
|
getLogger,
|
|
18
18
|
stripHexPrefix,
|
|
19
19
|
withSDKTelemetry
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FY7UU55U.js";
|
|
21
21
|
|
|
22
22
|
// src/client/common/contract/eip7702.ts
|
|
23
|
-
import {
|
|
24
|
-
encodeFunctionData as encodeFunctionData2,
|
|
25
|
-
encodeAbiParameters,
|
|
26
|
-
decodeErrorResult as decodeErrorResult2,
|
|
27
|
-
keccak256,
|
|
28
|
-
toBytes,
|
|
29
|
-
concat
|
|
30
|
-
} from "viem";
|
|
23
|
+
import { encodeFunctionData as encodeFunctionData2, encodeAbiParameters, decodeErrorResult as decodeErrorResult2 } from "viem";
|
|
31
24
|
|
|
32
25
|
// src/client/common/abis/ERC7702Delegator.json
|
|
33
26
|
var ERC7702Delegator_default = [
|
|
@@ -2756,20 +2749,20 @@ async function prepareDeployBatch(options, logger) {
|
|
|
2756
2749
|
environmentConfig
|
|
2757
2750
|
};
|
|
2758
2751
|
}
|
|
2759
|
-
async function executeDeployBatch(
|
|
2752
|
+
async function executeDeployBatch(data, context, gas, logger) {
|
|
2760
2753
|
const pendingMessage = "Deploying new app...";
|
|
2761
2754
|
const txHash = await executeBatch(
|
|
2762
2755
|
{
|
|
2763
|
-
walletClient:
|
|
2764
|
-
publicClient:
|
|
2765
|
-
environmentConfig:
|
|
2766
|
-
executions:
|
|
2756
|
+
walletClient: context.walletClient,
|
|
2757
|
+
publicClient: context.publicClient,
|
|
2758
|
+
environmentConfig: context.environmentConfig,
|
|
2759
|
+
executions: data.executions,
|
|
2767
2760
|
pendingMessage,
|
|
2768
2761
|
gas
|
|
2769
2762
|
},
|
|
2770
2763
|
logger
|
|
2771
2764
|
);
|
|
2772
|
-
return { appId:
|
|
2765
|
+
return { appId: data.appId, txHash };
|
|
2773
2766
|
}
|
|
2774
2767
|
async function deployApp(options, logger) {
|
|
2775
2768
|
const prepared = await prepareDeployBatch(
|
|
@@ -2783,7 +2776,17 @@ async function deployApp(options, logger) {
|
|
|
2783
2776
|
},
|
|
2784
2777
|
logger
|
|
2785
2778
|
);
|
|
2786
|
-
|
|
2779
|
+
const data = {
|
|
2780
|
+
appId: prepared.appId,
|
|
2781
|
+
salt: prepared.salt,
|
|
2782
|
+
executions: prepared.executions
|
|
2783
|
+
};
|
|
2784
|
+
const context = {
|
|
2785
|
+
walletClient: prepared.walletClient,
|
|
2786
|
+
publicClient: prepared.publicClient,
|
|
2787
|
+
environmentConfig: prepared.environmentConfig
|
|
2788
|
+
};
|
|
2789
|
+
return executeDeployBatch(data, context, options.gas, logger);
|
|
2787
2790
|
}
|
|
2788
2791
|
async function prepareUpgradeBatch(options) {
|
|
2789
2792
|
const {
|
|
@@ -2879,14 +2882,14 @@ async function prepareUpgradeBatch(options) {
|
|
|
2879
2882
|
environmentConfig
|
|
2880
2883
|
};
|
|
2881
2884
|
}
|
|
2882
|
-
async function executeUpgradeBatch(
|
|
2883
|
-
const pendingMessage = `Upgrading app ${
|
|
2885
|
+
async function executeUpgradeBatch(data, context, gas, logger) {
|
|
2886
|
+
const pendingMessage = `Upgrading app ${data.appId}...`;
|
|
2884
2887
|
const txHash = await executeBatch(
|
|
2885
2888
|
{
|
|
2886
|
-
walletClient:
|
|
2887
|
-
publicClient:
|
|
2888
|
-
environmentConfig:
|
|
2889
|
-
executions:
|
|
2889
|
+
walletClient: context.walletClient,
|
|
2890
|
+
publicClient: context.publicClient,
|
|
2891
|
+
environmentConfig: context.environmentConfig,
|
|
2892
|
+
executions: data.executions,
|
|
2890
2893
|
pendingMessage,
|
|
2891
2894
|
gas
|
|
2892
2895
|
},
|
|
@@ -2904,7 +2907,16 @@ async function upgradeApp(options, logger) {
|
|
|
2904
2907
|
publicLogs: options.publicLogs,
|
|
2905
2908
|
needsPermissionChange: options.needsPermissionChange
|
|
2906
2909
|
});
|
|
2907
|
-
|
|
2910
|
+
const data = {
|
|
2911
|
+
appId: prepared.appId,
|
|
2912
|
+
executions: prepared.executions
|
|
2913
|
+
};
|
|
2914
|
+
const context = {
|
|
2915
|
+
walletClient: prepared.walletClient,
|
|
2916
|
+
publicClient: prepared.publicClient,
|
|
2917
|
+
environmentConfig: prepared.environmentConfig
|
|
2918
|
+
};
|
|
2919
|
+
return executeUpgradeBatch(data, context, options.gas, logger);
|
|
2908
2920
|
}
|
|
2909
2921
|
async function sendAndWaitForTransaction(options, logger) {
|
|
2910
2922
|
const {
|
|
@@ -3195,27 +3207,55 @@ async function undelegate(options, logger) {
|
|
|
3195
3207
|
}
|
|
3196
3208
|
|
|
3197
3209
|
// src/client/common/contract/eip7702.ts
|
|
3210
|
+
var EXECUTE_BATCH_MODE = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
3211
|
+
var GAS_LIMIT_BUFFER_PERCENTAGE = 20n;
|
|
3212
|
+
var GAS_PRICE_BUFFER_PERCENTAGE = 100n;
|
|
3213
|
+
function encodeExecuteBatchData(executions) {
|
|
3214
|
+
const encodedExecutions = encodeAbiParameters(
|
|
3215
|
+
[
|
|
3216
|
+
{
|
|
3217
|
+
type: "tuple[]",
|
|
3218
|
+
components: [
|
|
3219
|
+
{ name: "target", type: "address" },
|
|
3220
|
+
{ name: "value", type: "uint256" },
|
|
3221
|
+
{ name: "callData", type: "bytes" }
|
|
3222
|
+
]
|
|
3223
|
+
}
|
|
3224
|
+
],
|
|
3225
|
+
[executions]
|
|
3226
|
+
);
|
|
3227
|
+
return encodeFunctionData2({
|
|
3228
|
+
abi: ERC7702Delegator_default,
|
|
3229
|
+
functionName: "execute",
|
|
3230
|
+
args: [EXECUTE_BATCH_MODE, encodedExecutions]
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3198
3233
|
async function estimateBatchGas(options) {
|
|
3199
|
-
const { publicClient, executions } = options;
|
|
3200
|
-
const
|
|
3201
|
-
const
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3234
|
+
const { publicClient, account, executions } = options;
|
|
3235
|
+
const executeBatchData = encodeExecuteBatchData(executions);
|
|
3236
|
+
const [gasTipCap, block, estimatedGas] = await Promise.all([
|
|
3237
|
+
publicClient.estimateMaxPriorityFeePerGas(),
|
|
3238
|
+
publicClient.getBlock(),
|
|
3239
|
+
publicClient.estimateGas({
|
|
3240
|
+
account,
|
|
3241
|
+
to: account,
|
|
3242
|
+
data: executeBatchData
|
|
3243
|
+
})
|
|
3244
|
+
]);
|
|
3245
|
+
const baseFee = block.baseFeePerGas ?? 0n;
|
|
3246
|
+
const maxFeePerGas = (baseFee + gasTipCap) * (100n + GAS_PRICE_BUFFER_PERCENTAGE) / 100n;
|
|
3247
|
+
const gasLimit = estimatedGas * (100n + GAS_LIMIT_BUFFER_PERCENTAGE) / 100n;
|
|
3207
3248
|
const maxCostWei = gasLimit * maxFeePerGas;
|
|
3208
|
-
const maxCostEth = formatETH(maxCostWei);
|
|
3209
3249
|
return {
|
|
3210
3250
|
gasLimit,
|
|
3211
3251
|
maxFeePerGas,
|
|
3212
|
-
maxPriorityFeePerGas,
|
|
3252
|
+
maxPriorityFeePerGas: gasTipCap,
|
|
3213
3253
|
maxCostWei,
|
|
3214
|
-
maxCostEth
|
|
3254
|
+
maxCostEth: formatETH(maxCostWei)
|
|
3215
3255
|
};
|
|
3216
3256
|
}
|
|
3217
3257
|
async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
|
|
3218
|
-
const code = await publicClient.
|
|
3258
|
+
const code = await publicClient.getCode({ address: account });
|
|
3219
3259
|
if (!code) {
|
|
3220
3260
|
return false;
|
|
3221
3261
|
}
|
|
@@ -3232,36 +3272,7 @@ async function executeBatch(options, logger) {
|
|
|
3232
3272
|
if (!chain) {
|
|
3233
3273
|
throw new Error("Wallet client must have a chain");
|
|
3234
3274
|
}
|
|
3235
|
-
const
|
|
3236
|
-
[
|
|
3237
|
-
{
|
|
3238
|
-
type: "tuple[]",
|
|
3239
|
-
components: [
|
|
3240
|
-
{ name: "target", type: "address" },
|
|
3241
|
-
{ name: "value", type: "uint256" },
|
|
3242
|
-
{ name: "callData", type: "bytes" }
|
|
3243
|
-
]
|
|
3244
|
-
}
|
|
3245
|
-
],
|
|
3246
|
-
[executions]
|
|
3247
|
-
);
|
|
3248
|
-
const executeBatchMode = "0x0100000000000000000000000000000000000000000000000000000000000000";
|
|
3249
|
-
let executeBatchData;
|
|
3250
|
-
try {
|
|
3251
|
-
executeBatchData = encodeFunctionData2({
|
|
3252
|
-
abi: ERC7702Delegator_default,
|
|
3253
|
-
functionName: "execute",
|
|
3254
|
-
args: [executeBatchMode, encodedExecutions]
|
|
3255
|
-
});
|
|
3256
|
-
} catch {
|
|
3257
|
-
const functionSignature = "execute(bytes32,bytes)";
|
|
3258
|
-
const selector = keccak256(toBytes(functionSignature)).slice(0, 10);
|
|
3259
|
-
const encodedParams = encodeAbiParameters(
|
|
3260
|
-
[{ type: "bytes32" }, { type: "bytes" }],
|
|
3261
|
-
[executeBatchMode, encodedExecutions]
|
|
3262
|
-
);
|
|
3263
|
-
executeBatchData = concat([selector, encodedParams]);
|
|
3264
|
-
}
|
|
3275
|
+
const executeBatchData = encodeExecuteBatchData(executions);
|
|
3265
3276
|
const isDelegated2 = await checkERC7702Delegation(
|
|
3266
3277
|
publicClient,
|
|
3267
3278
|
account.address,
|
|
@@ -3643,6 +3654,7 @@ async function buildDockerImage(buildContext, dockerfilePath, tag, logger) {
|
|
|
3643
3654
|
tag,
|
|
3644
3655
|
"-f",
|
|
3645
3656
|
dockerfilePath,
|
|
3657
|
+
"--load",
|
|
3646
3658
|
"--progress=plain",
|
|
3647
3659
|
buildContext
|
|
3648
3660
|
];
|
|
@@ -3766,9 +3778,9 @@ async function pullDockerImage(docker, imageTag, platform = "linux/amd64", logge
|
|
|
3766
3778
|
|
|
3767
3779
|
// src/client/common/docker/push.ts
|
|
3768
3780
|
import * as child_process2 from "child_process";
|
|
3769
|
-
import {
|
|
3781
|
+
import { execFile } from "child_process";
|
|
3770
3782
|
import { promisify as promisify2 } from "util";
|
|
3771
|
-
var
|
|
3783
|
+
var execFileAsync = promisify2(execFile);
|
|
3772
3784
|
async function pushDockerImage(docker, imageRef, logger) {
|
|
3773
3785
|
logger?.info?.(`Pushing image ${imageRef}...`);
|
|
3774
3786
|
return new Promise((resolve2, reject) => {
|
|
@@ -3809,9 +3821,9 @@ async function pushDockerImage(docker, imageRef, logger) {
|
|
|
3809
3821
|
if (!output.includes("digest:") && !output.includes("pushed") && !output.includes("Pushed")) {
|
|
3810
3822
|
logger?.debug?.("No clear success indicator in push output, verifying...");
|
|
3811
3823
|
}
|
|
3812
|
-
logger?.info?.("Image push completed successfully");
|
|
3813
3824
|
try {
|
|
3814
3825
|
await verifyImageExists(imageRef, logger);
|
|
3826
|
+
logger?.info?.("Image push completed successfully");
|
|
3815
3827
|
resolve2();
|
|
3816
3828
|
} catch (error) {
|
|
3817
3829
|
reject(error);
|
|
@@ -3835,7 +3847,7 @@ async function verifyImageExists(imageRef, logger) {
|
|
|
3835
3847
|
let retries = 5;
|
|
3836
3848
|
while (retries > 0) {
|
|
3837
3849
|
try {
|
|
3838
|
-
await
|
|
3850
|
+
await execFileAsync("docker", ["manifest", "inspect", imageRef], {
|
|
3839
3851
|
maxBuffer: 10 * 1024 * 1024,
|
|
3840
3852
|
timeout: 1e4
|
|
3841
3853
|
// 10 second timeout
|
|
@@ -4293,10 +4305,10 @@ async function setupLayeredBuildDirectory(environmentConfig, layeredDockerfileCo
|
|
|
4293
4305
|
// src/client/common/registry/digest.ts
|
|
4294
4306
|
import * as child_process3 from "child_process";
|
|
4295
4307
|
import { promisify as promisify3 } from "util";
|
|
4296
|
-
var
|
|
4308
|
+
var execFileAsync2 = promisify3(child_process3.execFile);
|
|
4297
4309
|
async function getImageDigestAndName(imageRef) {
|
|
4298
4310
|
try {
|
|
4299
|
-
const { stdout } = await
|
|
4311
|
+
const { stdout } = await execFileAsync2(
|
|
4300
4312
|
"docker",
|
|
4301
4313
|
["manifest", "inspect", imageRef],
|
|
4302
4314
|
{ maxBuffer: 10 * 1024 * 1024 }
|
|
@@ -4336,7 +4348,7 @@ function extractDigestFromMultiPlatform(manifest, imageRef) {
|
|
|
4336
4348
|
}
|
|
4337
4349
|
async function extractDigestFromSinglePlatform(manifest, imageRef) {
|
|
4338
4350
|
try {
|
|
4339
|
-
const { stdout } = await
|
|
4351
|
+
const { stdout } = await execFileAsync2("docker", ["inspect", imageRef], {
|
|
4340
4352
|
maxBuffer: 10 * 1024 * 1024
|
|
4341
4353
|
});
|
|
4342
4354
|
const inspectData = JSON.parse(stdout);
|
|
@@ -4653,7 +4665,10 @@ async function createReleaseFromImageDigest(options, logger) {
|
|
|
4653
4665
|
publicEnv["EIGEN_MACHINE_TYPE_PUBLIC"] = instanceType;
|
|
4654
4666
|
logger.info(`Instance type: ${instanceType}`);
|
|
4655
4667
|
logger.info("Encrypting environment variables...");
|
|
4656
|
-
const { encryptionKey } = getKMSKeysForEnvironment(
|
|
4668
|
+
const { encryptionKey } = getKMSKeysForEnvironment(
|
|
4669
|
+
environmentConfig.name,
|
|
4670
|
+
environmentConfig.build
|
|
4671
|
+
);
|
|
4657
4672
|
const protectedHeaders = getAppProtectedHeaders(appId);
|
|
4658
4673
|
const privateEnvBytes = Buffer.from(JSON.stringify(privateEnv));
|
|
4659
4674
|
const encryptedEnvStr = await encryptRSAOAEPAndAES256GCM(
|
|
@@ -4890,7 +4905,9 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
|
|
|
4890
4905
|
validateAppName(options.appName);
|
|
4891
4906
|
validateLogVisibility(options.logVisibility);
|
|
4892
4907
|
if (!/^sha256:[0-9a-f]{64}$/i.test(options.imageDigest)) {
|
|
4893
|
-
throw new Error(
|
|
4908
|
+
throw new Error(
|
|
4909
|
+
`imageDigest must be in format sha256:<64 hex>, got: ${options.imageDigest}`
|
|
4910
|
+
);
|
|
4894
4911
|
}
|
|
4895
4912
|
const { publicLogs } = validateLogVisibility(options.logVisibility);
|
|
4896
4913
|
validateResourceUsageMonitoring(options.resourceUsageMonitoring);
|
|
@@ -4943,19 +4960,19 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
|
|
|
4943
4960
|
logger.debug("Estimating gas...");
|
|
4944
4961
|
const gasEstimate = await estimateBatchGas({
|
|
4945
4962
|
publicClient: batch.publicClient,
|
|
4946
|
-
|
|
4963
|
+
account: batch.walletClient.account.address,
|
|
4947
4964
|
executions: batch.executions
|
|
4948
4965
|
});
|
|
4966
|
+
const data = {
|
|
4967
|
+
appId: batch.appId,
|
|
4968
|
+
salt: batch.salt,
|
|
4969
|
+
executions: batch.executions
|
|
4970
|
+
};
|
|
4949
4971
|
return {
|
|
4950
4972
|
prepared: {
|
|
4951
|
-
|
|
4973
|
+
data,
|
|
4952
4974
|
appName: options.appName,
|
|
4953
|
-
imageRef: options.imageRef
|
|
4954
|
-
preflightCtx: {
|
|
4955
|
-
privateKey: preflightCtx.privateKey,
|
|
4956
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
4957
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
4958
|
-
}
|
|
4975
|
+
imageRef: options.imageRef
|
|
4959
4976
|
},
|
|
4960
4977
|
gasEstimate
|
|
4961
4978
|
};
|
|
@@ -5182,26 +5199,27 @@ async function prepareDeploy(options, logger = defaultLogger) {
|
|
|
5182
5199
|
logger.debug("Estimating gas...");
|
|
5183
5200
|
const gasEstimate = await estimateBatchGas({
|
|
5184
5201
|
publicClient: batch.publicClient,
|
|
5185
|
-
|
|
5202
|
+
account: batch.walletClient.account.address,
|
|
5186
5203
|
executions: batch.executions
|
|
5187
5204
|
});
|
|
5205
|
+
const data = {
|
|
5206
|
+
appId: batch.appId,
|
|
5207
|
+
salt: batch.salt,
|
|
5208
|
+
executions: batch.executions
|
|
5209
|
+
};
|
|
5188
5210
|
return {
|
|
5189
5211
|
prepared: {
|
|
5190
|
-
|
|
5212
|
+
data,
|
|
5191
5213
|
appName,
|
|
5192
|
-
imageRef: finalImageRef
|
|
5193
|
-
preflightCtx: {
|
|
5194
|
-
privateKey: preflightCtx.privateKey,
|
|
5195
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
5196
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
5197
|
-
}
|
|
5214
|
+
imageRef: finalImageRef
|
|
5198
5215
|
},
|
|
5199
5216
|
gasEstimate
|
|
5200
5217
|
};
|
|
5201
5218
|
}
|
|
5202
5219
|
);
|
|
5203
5220
|
}
|
|
5204
|
-
async function executeDeploy(
|
|
5221
|
+
async function executeDeploy(options) {
|
|
5222
|
+
const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
|
|
5205
5223
|
return withSDKTelemetry(
|
|
5206
5224
|
{
|
|
5207
5225
|
functionName: "executeDeploy",
|
|
@@ -5209,7 +5227,7 @@ async function executeDeploy(prepared, gas, logger = defaultLogger, skipTelemetr
|
|
|
5209
5227
|
},
|
|
5210
5228
|
async () => {
|
|
5211
5229
|
logger.info("Deploying on-chain...");
|
|
5212
|
-
const { appId, txHash } = await executeDeployBatch(prepared.
|
|
5230
|
+
const { appId, txHash } = await executeDeployBatch(prepared.data, context, gas, logger);
|
|
5213
5231
|
return {
|
|
5214
5232
|
appId,
|
|
5215
5233
|
txHash,
|
|
@@ -5328,19 +5346,18 @@ async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger
|
|
|
5328
5346
|
logger.debug("Estimating gas...");
|
|
5329
5347
|
const gasEstimate = await estimateBatchGas({
|
|
5330
5348
|
publicClient: batch.publicClient,
|
|
5331
|
-
|
|
5349
|
+
account: batch.walletClient.account.address,
|
|
5332
5350
|
executions: batch.executions
|
|
5333
5351
|
});
|
|
5352
|
+
const data = {
|
|
5353
|
+
appId: batch.appId,
|
|
5354
|
+
executions: batch.executions
|
|
5355
|
+
};
|
|
5334
5356
|
return {
|
|
5335
5357
|
prepared: {
|
|
5336
|
-
|
|
5358
|
+
data,
|
|
5337
5359
|
appId: appID,
|
|
5338
|
-
imageRef: options.imageRef
|
|
5339
|
-
preflightCtx: {
|
|
5340
|
-
privateKey: preflightCtx.privateKey,
|
|
5341
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
5342
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
5343
|
-
}
|
|
5360
|
+
imageRef: options.imageRef
|
|
5344
5361
|
},
|
|
5345
5362
|
gasEstimate
|
|
5346
5363
|
};
|
|
@@ -5509,26 +5526,26 @@ async function prepareUpgrade(options, logger = defaultLogger) {
|
|
|
5509
5526
|
logger.debug("Estimating gas...");
|
|
5510
5527
|
const gasEstimate = await estimateBatchGas({
|
|
5511
5528
|
publicClient: batch.publicClient,
|
|
5512
|
-
|
|
5529
|
+
account: batch.walletClient.account.address,
|
|
5513
5530
|
executions: batch.executions
|
|
5514
5531
|
});
|
|
5532
|
+
const data = {
|
|
5533
|
+
appId: batch.appId,
|
|
5534
|
+
executions: batch.executions
|
|
5535
|
+
};
|
|
5515
5536
|
return {
|
|
5516
5537
|
prepared: {
|
|
5517
|
-
|
|
5538
|
+
data,
|
|
5518
5539
|
appId: appID,
|
|
5519
|
-
imageRef: finalImageRef
|
|
5520
|
-
preflightCtx: {
|
|
5521
|
-
privateKey: preflightCtx.privateKey,
|
|
5522
|
-
rpcUrl: preflightCtx.rpcUrl,
|
|
5523
|
-
environmentConfig: preflightCtx.environmentConfig
|
|
5524
|
-
}
|
|
5540
|
+
imageRef: finalImageRef
|
|
5525
5541
|
},
|
|
5526
5542
|
gasEstimate
|
|
5527
5543
|
};
|
|
5528
5544
|
}
|
|
5529
5545
|
);
|
|
5530
5546
|
}
|
|
5531
|
-
async function executeUpgrade(
|
|
5547
|
+
async function executeUpgrade(options) {
|
|
5548
|
+
const { prepared, context, gas, logger = defaultLogger, skipTelemetry } = options;
|
|
5532
5549
|
return withSDKTelemetry(
|
|
5533
5550
|
{
|
|
5534
5551
|
functionName: "executeUpgrade",
|
|
@@ -5536,7 +5553,7 @@ async function executeUpgrade(prepared, gas, logger = defaultLogger, skipTelemet
|
|
|
5536
5553
|
},
|
|
5537
5554
|
async () => {
|
|
5538
5555
|
logger.info("Upgrading on-chain...");
|
|
5539
|
-
const txHash = await executeUpgradeBatch(prepared.
|
|
5556
|
+
const txHash = await executeUpgradeBatch(prepared.data, context, gas, logger);
|
|
5540
5557
|
return {
|
|
5541
5558
|
appId: prepared.appId,
|
|
5542
5559
|
imageRef: prepared.imageRef,
|
|
@@ -5665,10 +5682,10 @@ import * as path6 from "path";
|
|
|
5665
5682
|
import * as fs5 from "fs";
|
|
5666
5683
|
import * as path4 from "path";
|
|
5667
5684
|
import * as os2 from "os";
|
|
5668
|
-
import { exec as
|
|
5685
|
+
import { exec as exec3, execFile as execFile3 } from "child_process";
|
|
5669
5686
|
import { promisify as promisify4 } from "util";
|
|
5670
|
-
var
|
|
5671
|
-
var
|
|
5687
|
+
var execAsync = promisify4(exec3);
|
|
5688
|
+
var execFileAsync3 = promisify4(execFile3);
|
|
5672
5689
|
async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
5673
5690
|
if (!repoURL) {
|
|
5674
5691
|
throw new Error("repoURL is required");
|
|
@@ -5677,13 +5694,13 @@ async function fetchTemplate(repoURL, ref, targetDir, config, logger) {
|
|
|
5677
5694
|
Cloning repo: ${repoURL} \u2192 ${targetDir}
|
|
5678
5695
|
`);
|
|
5679
5696
|
try {
|
|
5680
|
-
await
|
|
5697
|
+
await execAsync(`git clone --no-checkout --progress ${repoURL} ${targetDir}`, {
|
|
5681
5698
|
maxBuffer: 10 * 1024 * 1024
|
|
5682
5699
|
});
|
|
5683
|
-
await
|
|
5700
|
+
await execFileAsync3("git", ["-C", targetDir, "checkout", "--quiet", ref], {
|
|
5684
5701
|
maxBuffer: 10 * 1024 * 1024
|
|
5685
5702
|
});
|
|
5686
|
-
await
|
|
5703
|
+
await execFileAsync3(
|
|
5687
5704
|
"git",
|
|
5688
5705
|
["-C", targetDir, "submodule", "update", "--init", "--recursive", "--progress"],
|
|
5689
5706
|
{ maxBuffer: 10 * 1024 * 1024 }
|
|
@@ -5728,14 +5745,14 @@ Cloning template: ${repoURL} \u2192 extracting ${subPath}
|
|
|
5728
5745
|
}
|
|
5729
5746
|
async function cloneSparse(repoURL, ref, subPath, tempDir) {
|
|
5730
5747
|
try {
|
|
5731
|
-
await
|
|
5732
|
-
await
|
|
5733
|
-
await
|
|
5748
|
+
await execFileAsync3("git", ["init", tempDir]);
|
|
5749
|
+
await execFileAsync3("git", ["-C", tempDir, "remote", "add", "origin", repoURL]);
|
|
5750
|
+
await execFileAsync3("git", ["-C", tempDir, "config", "core.sparseCheckout", "true"]);
|
|
5734
5751
|
const sparseCheckoutPath = path4.join(tempDir, ".git/info/sparse-checkout");
|
|
5735
5752
|
fs5.writeFileSync(sparseCheckoutPath, `${subPath}
|
|
5736
5753
|
`);
|
|
5737
|
-
await
|
|
5738
|
-
await
|
|
5754
|
+
await execFileAsync3("git", ["-C", tempDir, "fetch", "origin", ref]);
|
|
5755
|
+
await execFileAsync3("git", ["-C", tempDir, "checkout", ref]);
|
|
5739
5756
|
} catch (error) {
|
|
5740
5757
|
throw new Error(`Failed to clone sparse repository: ${error.message}`);
|
|
5741
5758
|
}
|
|
@@ -6228,7 +6245,14 @@ async function logs(options, logger = defaultLogger, skipTelemetry = false) {
|
|
|
6228
6245
|
}
|
|
6229
6246
|
|
|
6230
6247
|
// src/client/modules/compute/app/index.ts
|
|
6231
|
-
import {
|
|
6248
|
+
import {
|
|
6249
|
+
parseAbi,
|
|
6250
|
+
encodeFunctionData as encodeFunctionData3,
|
|
6251
|
+
createWalletClient as createWalletClient2,
|
|
6252
|
+
createPublicClient as createPublicClient4,
|
|
6253
|
+
http as http4
|
|
6254
|
+
} from "viem";
|
|
6255
|
+
import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
|
|
6232
6256
|
var CONTROLLER_ABI = parseAbi([
|
|
6233
6257
|
"function startApp(address appId)",
|
|
6234
6258
|
"function stopApp(address appId)",
|
|
@@ -6311,6 +6335,187 @@ function createAppModule(ctx) {
|
|
|
6311
6335
|
imageRef: result.imageRef
|
|
6312
6336
|
};
|
|
6313
6337
|
},
|
|
6338
|
+
// Granular deploy control
|
|
6339
|
+
async prepareDeploy(opts) {
|
|
6340
|
+
return prepareDeploy(
|
|
6341
|
+
{
|
|
6342
|
+
privateKey,
|
|
6343
|
+
rpcUrl: ctx.rpcUrl,
|
|
6344
|
+
environment: ctx.environment,
|
|
6345
|
+
appName: opts.name,
|
|
6346
|
+
instanceType: opts.instanceType,
|
|
6347
|
+
dockerfilePath: opts.dockerfile,
|
|
6348
|
+
envFilePath: opts.envFile,
|
|
6349
|
+
imageRef: opts.imageRef,
|
|
6350
|
+
logVisibility: opts.logVisibility,
|
|
6351
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
6352
|
+
skipTelemetry
|
|
6353
|
+
},
|
|
6354
|
+
logger
|
|
6355
|
+
);
|
|
6356
|
+
},
|
|
6357
|
+
async prepareDeployFromVerifiableBuild(opts) {
|
|
6358
|
+
return prepareDeployFromVerifiableBuild(
|
|
6359
|
+
{
|
|
6360
|
+
privateKey,
|
|
6361
|
+
rpcUrl: ctx.rpcUrl,
|
|
6362
|
+
environment: ctx.environment,
|
|
6363
|
+
appName: opts.name,
|
|
6364
|
+
instanceType: opts.instanceType,
|
|
6365
|
+
envFilePath: opts.envFile,
|
|
6366
|
+
imageRef: opts.imageRef,
|
|
6367
|
+
imageDigest: opts.imageDigest,
|
|
6368
|
+
logVisibility: opts.logVisibility,
|
|
6369
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
6370
|
+
skipTelemetry
|
|
6371
|
+
},
|
|
6372
|
+
logger
|
|
6373
|
+
);
|
|
6374
|
+
},
|
|
6375
|
+
async executeDeploy(prepared, gas) {
|
|
6376
|
+
const account = privateKeyToAccount3(privateKey);
|
|
6377
|
+
const chain = getChainFromID(environment.chainID);
|
|
6378
|
+
const publicClient = createPublicClient4({
|
|
6379
|
+
chain,
|
|
6380
|
+
transport: http4(ctx.rpcUrl)
|
|
6381
|
+
});
|
|
6382
|
+
const walletClient = createWalletClient2({
|
|
6383
|
+
account,
|
|
6384
|
+
chain,
|
|
6385
|
+
transport: http4(ctx.rpcUrl)
|
|
6386
|
+
});
|
|
6387
|
+
const result = await executeDeploy({
|
|
6388
|
+
prepared,
|
|
6389
|
+
context: {
|
|
6390
|
+
walletClient,
|
|
6391
|
+
publicClient,
|
|
6392
|
+
environmentConfig: environment
|
|
6393
|
+
},
|
|
6394
|
+
gas,
|
|
6395
|
+
logger,
|
|
6396
|
+
skipTelemetry
|
|
6397
|
+
});
|
|
6398
|
+
return {
|
|
6399
|
+
appId: result.appId,
|
|
6400
|
+
txHash: result.txHash,
|
|
6401
|
+
appName: result.appName,
|
|
6402
|
+
imageRef: result.imageRef
|
|
6403
|
+
};
|
|
6404
|
+
},
|
|
6405
|
+
async watchDeployment(appId) {
|
|
6406
|
+
return watchDeployment(
|
|
6407
|
+
appId,
|
|
6408
|
+
privateKey,
|
|
6409
|
+
ctx.rpcUrl,
|
|
6410
|
+
ctx.environment,
|
|
6411
|
+
logger,
|
|
6412
|
+
ctx.clientId,
|
|
6413
|
+
skipTelemetry
|
|
6414
|
+
);
|
|
6415
|
+
},
|
|
6416
|
+
// Granular upgrade control
|
|
6417
|
+
async prepareUpgrade(appId, opts) {
|
|
6418
|
+
return prepareUpgrade(
|
|
6419
|
+
{
|
|
6420
|
+
appId,
|
|
6421
|
+
privateKey,
|
|
6422
|
+
rpcUrl: ctx.rpcUrl,
|
|
6423
|
+
environment: ctx.environment,
|
|
6424
|
+
instanceType: opts.instanceType,
|
|
6425
|
+
dockerfilePath: opts.dockerfile,
|
|
6426
|
+
envFilePath: opts.envFile,
|
|
6427
|
+
imageRef: opts.imageRef,
|
|
6428
|
+
logVisibility: opts.logVisibility,
|
|
6429
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
6430
|
+
skipTelemetry
|
|
6431
|
+
},
|
|
6432
|
+
logger
|
|
6433
|
+
);
|
|
6434
|
+
},
|
|
6435
|
+
async prepareUpgradeFromVerifiableBuild(appId, opts) {
|
|
6436
|
+
return prepareUpgradeFromVerifiableBuild(
|
|
6437
|
+
{
|
|
6438
|
+
appId,
|
|
6439
|
+
privateKey,
|
|
6440
|
+
rpcUrl: ctx.rpcUrl,
|
|
6441
|
+
environment: ctx.environment,
|
|
6442
|
+
instanceType: opts.instanceType,
|
|
6443
|
+
envFilePath: opts.envFile,
|
|
6444
|
+
imageRef: opts.imageRef,
|
|
6445
|
+
imageDigest: opts.imageDigest,
|
|
6446
|
+
logVisibility: opts.logVisibility,
|
|
6447
|
+
resourceUsageMonitoring: opts.resourceUsageMonitoring,
|
|
6448
|
+
skipTelemetry
|
|
6449
|
+
},
|
|
6450
|
+
logger
|
|
6451
|
+
);
|
|
6452
|
+
},
|
|
6453
|
+
async executeUpgrade(prepared, gas) {
|
|
6454
|
+
const account = privateKeyToAccount3(privateKey);
|
|
6455
|
+
const chain = getChainFromID(environment.chainID);
|
|
6456
|
+
const publicClient = createPublicClient4({
|
|
6457
|
+
chain,
|
|
6458
|
+
transport: http4(ctx.rpcUrl)
|
|
6459
|
+
});
|
|
6460
|
+
const walletClient = createWalletClient2({
|
|
6461
|
+
account,
|
|
6462
|
+
chain,
|
|
6463
|
+
transport: http4(ctx.rpcUrl)
|
|
6464
|
+
});
|
|
6465
|
+
const result = await executeUpgrade({
|
|
6466
|
+
prepared,
|
|
6467
|
+
context: {
|
|
6468
|
+
walletClient,
|
|
6469
|
+
publicClient,
|
|
6470
|
+
environmentConfig: environment
|
|
6471
|
+
},
|
|
6472
|
+
gas,
|
|
6473
|
+
logger,
|
|
6474
|
+
skipTelemetry
|
|
6475
|
+
});
|
|
6476
|
+
return {
|
|
6477
|
+
appId: result.appId,
|
|
6478
|
+
txHash: result.txHash,
|
|
6479
|
+
imageRef: result.imageRef
|
|
6480
|
+
};
|
|
6481
|
+
},
|
|
6482
|
+
async watchUpgrade(appId) {
|
|
6483
|
+
return watchUpgrade(
|
|
6484
|
+
appId,
|
|
6485
|
+
privateKey,
|
|
6486
|
+
ctx.rpcUrl,
|
|
6487
|
+
ctx.environment,
|
|
6488
|
+
logger,
|
|
6489
|
+
ctx.clientId,
|
|
6490
|
+
skipTelemetry
|
|
6491
|
+
);
|
|
6492
|
+
},
|
|
6493
|
+
// Profile management
|
|
6494
|
+
async setProfile(appId, profile) {
|
|
6495
|
+
return withSDKTelemetry(
|
|
6496
|
+
{
|
|
6497
|
+
functionName: "setProfile",
|
|
6498
|
+
skipTelemetry,
|
|
6499
|
+
properties: { environment: ctx.environment }
|
|
6500
|
+
},
|
|
6501
|
+
async () => {
|
|
6502
|
+
const userApiClient = new UserApiClient(
|
|
6503
|
+
environment,
|
|
6504
|
+
privateKey,
|
|
6505
|
+
ctx.rpcUrl,
|
|
6506
|
+
ctx.clientId
|
|
6507
|
+
);
|
|
6508
|
+
return userApiClient.uploadAppProfile(
|
|
6509
|
+
appId,
|
|
6510
|
+
profile.name,
|
|
6511
|
+
profile.website,
|
|
6512
|
+
profile.description,
|
|
6513
|
+
profile.xURL,
|
|
6514
|
+
profile.imagePath
|
|
6515
|
+
);
|
|
6516
|
+
}
|
|
6517
|
+
);
|
|
6518
|
+
},
|
|
6314
6519
|
async logs(opts) {
|
|
6315
6520
|
return logs(
|
|
6316
6521
|
{
|
|
@@ -6511,4 +6716,4 @@ export {
|
|
|
6511
6716
|
createAppModule,
|
|
6512
6717
|
createComputeModule
|
|
6513
6718
|
};
|
|
6514
|
-
//# sourceMappingURL=chunk-
|
|
6719
|
+
//# sourceMappingURL=chunk-O7EU5JL7.js.map
|