@layr-labs/ecloud-sdk 0.3.0-dev.0 → 0.3.1-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { Address, WalletClient, PublicClient, Hex } from 'viem';
2
- import { ab as Logger, a6 as EnvironmentConfig, N as DeployAppOpts, A as AppId, O as UpgradeAppOpts, Q as PrepareDeployOpts, $ as PreparedDeploy, G as GasEstimate, T as PrepareDeployFromVerifiableBuildOpts, X as ExecuteDeployResult, R as PrepareUpgradeOpts, a0 as PreparedUpgrade, V as PrepareUpgradeFromVerifiableBuildOpts, Y as ExecuteUpgradeResult, ac as AppProfile, ad as AppProfileResponse, a1 as LifecycleOpts } from './index-5y9NG_Id.js';
2
+ import { ab as Logger, a6 as EnvironmentConfig, N as DeployAppOpts, A as AppId, O as UpgradeAppOpts, Q as PrepareDeployOpts, $ as PreparedDeploy, G as GasEstimate, T as PrepareDeployFromVerifiableBuildOpts, X as ExecuteDeployResult, R as PrepareUpgradeOpts, a0 as PreparedUpgrade, V as PrepareUpgradeFromVerifiableBuildOpts, Y as ExecuteUpgradeResult, ac as AppProfile, ad as AppProfileResponse, a1 as LifecycleOpts } from './index-DeQzn_yM.js';
3
3
 
4
4
  /**
5
5
  * Create command
@@ -1,5 +1,5 @@
1
1
  import { Address, WalletClient, PublicClient, Hex } from 'viem';
2
- import { ab as Logger, a6 as EnvironmentConfig, N as DeployAppOpts, A as AppId, O as UpgradeAppOpts, Q as PrepareDeployOpts, $ as PreparedDeploy, G as GasEstimate, T as PrepareDeployFromVerifiableBuildOpts, X as ExecuteDeployResult, R as PrepareUpgradeOpts, a0 as PreparedUpgrade, V as PrepareUpgradeFromVerifiableBuildOpts, Y as ExecuteUpgradeResult, ac as AppProfile, ad as AppProfileResponse, a1 as LifecycleOpts } from './index-5y9NG_Id.cjs';
2
+ import { ab as Logger, a6 as EnvironmentConfig, N as DeployAppOpts, A as AppId, O as UpgradeAppOpts, Q as PrepareDeployOpts, $ as PreparedDeploy, G as GasEstimate, T as PrepareDeployFromVerifiableBuildOpts, X as ExecuteDeployResult, R as PrepareUpgradeOpts, a0 as PreparedUpgrade, V as PrepareUpgradeFromVerifiableBuildOpts, Y as ExecuteUpgradeResult, ac as AppProfile, ad as AppProfileResponse, a1 as LifecycleOpts } from './index-DeQzn_yM.cjs';
3
3
 
4
4
  /**
5
5
  * Create command
package/dist/compute.cjs CHANGED
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
- };
11
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,131 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
27
  ));
31
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
29
 
33
- // src/client/common/auth/session.ts
34
- function stripHexPrefix2(hex) {
35
- return hex.startsWith("0x") ? hex.slice(2) : hex;
36
- }
37
- async function parseErrorResponse(response) {
38
- try {
39
- const data = await response.json();
40
- return data.error || response.statusText;
41
- } catch {
42
- return response.statusText;
43
- }
44
- }
45
- async function loginToComputeApi(config, request) {
46
- let response;
47
- try {
48
- response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
49
- method: "POST",
50
- credentials: "include",
51
- // Include cookies for session management
52
- headers: {
53
- "Content-Type": "application/json"
54
- },
55
- body: JSON.stringify({
56
- message: request.message,
57
- signature: stripHexPrefix2(request.signature)
58
- })
59
- });
60
- } catch (error) {
61
- throw new SessionError(
62
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
63
- "NETWORK_ERROR"
64
- );
65
- }
66
- if (!response.ok) {
67
- const errorMessage = await parseErrorResponse(response);
68
- const status = response.status;
69
- if (status === 400) {
70
- if (errorMessage.toLowerCase().includes("siwe")) {
71
- throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
72
- }
73
- throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
74
- }
75
- if (status === 401) {
76
- throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
77
- }
78
- throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
79
- }
80
- const data = await response.json();
81
- return {
82
- success: data.success,
83
- address: data.address
84
- };
85
- }
86
- async function getComputeApiSession(config) {
87
- let response;
88
- try {
89
- response = await fetch(`${config.baseUrl}/auth/session`, {
90
- method: "GET",
91
- credentials: "include",
92
- // Include cookies for session management
93
- headers: {
94
- "Content-Type": "application/json"
95
- }
96
- });
97
- } catch {
98
- return {
99
- authenticated: false
100
- };
101
- }
102
- if (response.status === 401) {
103
- return {
104
- authenticated: false
105
- };
106
- }
107
- if (!response.ok) {
108
- const errorMessage = await parseErrorResponse(response);
109
- throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
110
- }
111
- const data = await response.json();
112
- return {
113
- authenticated: data.authenticated,
114
- address: data.address,
115
- chainId: data.chain_id
116
- };
117
- }
118
- async function logoutFromComputeApi(config) {
119
- let response;
120
- try {
121
- response = await fetch(`${config.baseUrl}/auth/logout`, {
122
- method: "POST",
123
- credentials: "include",
124
- // Include cookies for session management
125
- headers: {
126
- "Content-Type": "application/json"
127
- }
128
- });
129
- } catch (error) {
130
- throw new SessionError(
131
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
132
- "NETWORK_ERROR"
133
- );
134
- }
135
- if (response.status === 401) {
136
- return;
137
- }
138
- if (!response.ok) {
139
- const errorMessage = await parseErrorResponse(response);
140
- throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
141
- }
142
- }
143
- var SessionError;
144
- var init_session = __esm({
145
- "src/client/common/auth/session.ts"() {
146
- "use strict";
147
- SessionError = class extends Error {
148
- constructor(message, code, statusCode) {
149
- super(message);
150
- this.code = code;
151
- this.statusCode = statusCode;
152
- this.name = "SessionError";
153
- }
154
- };
155
- }
156
- });
157
-
158
30
  // src/compute.ts
159
31
  var compute_exports = {};
160
32
  __export(compute_exports, {
@@ -2336,7 +2208,7 @@ function encodeExecuteBatchData(executions) {
2336
2208
  });
2337
2209
  }
2338
2210
  async function estimateBatchGas(options) {
2339
- const { publicClient, account, executions, authorizationList } = options;
2211
+ const { publicClient, account, executions } = options;
2340
2212
  const executeBatchData = encodeExecuteBatchData(executions);
2341
2213
  const [gasTipCap, block, estimatedGas] = await Promise.all([
2342
2214
  publicClient.estimateMaxPriorityFeePerGas(),
@@ -2344,8 +2216,7 @@ async function estimateBatchGas(options) {
2344
2216
  publicClient.estimateGas({
2345
2217
  account,
2346
2218
  to: account,
2347
- data: executeBatchData,
2348
- authorizationList
2219
+ data: executeBatchData
2349
2220
  })
2350
2221
  ]);
2351
2222
  const baseFee = block.baseFeePerGas ?? 0n;
@@ -2368,44 +2239,8 @@ async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
2368
2239
  const expectedCode = `0xef0100${delegatorAddress.slice(2)}`;
2369
2240
  return code.toLowerCase() === expectedCode.toLowerCase();
2370
2241
  }
2371
- async function createAuthorizationList(options) {
2372
- const { walletClient, publicClient, environmentConfig } = options;
2373
- const account = walletClient.account;
2374
- if (!account) {
2375
- throw new Error("Wallet client must have an account");
2376
- }
2377
- const isDelegated2 = await checkERC7702Delegation(
2378
- publicClient,
2379
- account.address,
2380
- environmentConfig.erc7702DelegatorAddress
2381
- );
2382
- if (isDelegated2) {
2383
- return void 0;
2384
- }
2385
- const transactionNonce = await publicClient.getTransactionCount({
2386
- address: account.address,
2387
- blockTag: "pending"
2388
- });
2389
- const chainId = await publicClient.getChainId();
2390
- const authorizationNonce = transactionNonce + 1;
2391
- const signedAuthorization = await walletClient.signAuthorization({
2392
- account,
2393
- contractAddress: environmentConfig.erc7702DelegatorAddress,
2394
- chainId,
2395
- nonce: Number(authorizationNonce)
2396
- });
2397
- return [signedAuthorization];
2398
- }
2399
2242
  async function executeBatch(options, logger = noopLogger) {
2400
- const {
2401
- walletClient,
2402
- publicClient,
2403
- environmentConfig,
2404
- executions,
2405
- pendingMessage,
2406
- gas,
2407
- authorizationList: providedAuthList
2408
- } = options;
2243
+ const { walletClient, publicClient, environmentConfig, executions, pendingMessage, gas } = options;
2409
2244
  const account = walletClient.account;
2410
2245
  if (!account) {
2411
2246
  throw new Error("Wallet client must have an account");
@@ -2415,29 +2250,27 @@ async function executeBatch(options, logger = noopLogger) {
2415
2250
  throw new Error("Wallet client must have a chain");
2416
2251
  }
2417
2252
  const executeBatchData = encodeExecuteBatchData(executions);
2418
- let authorizationList = providedAuthList || [];
2419
- if (authorizationList.length === 0) {
2420
- const isDelegated2 = await checkERC7702Delegation(
2421
- publicClient,
2422
- account.address,
2423
- environmentConfig.erc7702DelegatorAddress
2424
- );
2425
- if (!isDelegated2) {
2426
- const transactionNonce = await publicClient.getTransactionCount({
2427
- address: account.address,
2428
- blockTag: "pending"
2429
- });
2430
- const chainId = await publicClient.getChainId();
2431
- const authorizationNonce = transactionNonce + 1;
2432
- logger.debug("Using wallet client signing for EIP-7702 authorization");
2433
- const signedAuthorization = await walletClient.signAuthorization({
2434
- account,
2435
- contractAddress: environmentConfig.erc7702DelegatorAddress,
2436
- chainId,
2437
- nonce: Number(authorizationNonce)
2438
- });
2439
- authorizationList = [signedAuthorization];
2440
- }
2253
+ const isDelegated2 = await checkERC7702Delegation(
2254
+ publicClient,
2255
+ account.address,
2256
+ environmentConfig.erc7702DelegatorAddress
2257
+ );
2258
+ let authorizationList = [];
2259
+ if (!isDelegated2) {
2260
+ const transactionNonce = await publicClient.getTransactionCount({
2261
+ address: account.address,
2262
+ blockTag: "pending"
2263
+ });
2264
+ const chainId = await publicClient.getChainId();
2265
+ const authorizationNonce = transactionNonce + 1;
2266
+ logger.debug("Using wallet client signing for EIP-7702 authorization");
2267
+ const signedAuthorization = await walletClient.signAuthorization({
2268
+ account: account.address,
2269
+ contractAddress: environmentConfig.erc7702DelegatorAddress,
2270
+ chainId,
2271
+ nonce: Number(authorizationNonce)
2272
+ });
2273
+ authorizationList = [signedAuthorization];
2441
2274
  }
2442
2275
  if (pendingMessage) {
2443
2276
  logger.info(pendingMessage);
@@ -2452,9 +2285,6 @@ async function executeBatch(options, logger = noopLogger) {
2452
2285
  if (authorizationList.length > 0) {
2453
2286
  txRequest.authorizationList = authorizationList;
2454
2287
  }
2455
- if (gas?.gasLimit) {
2456
- txRequest.gas = gas.gasLimit;
2457
- }
2458
2288
  if (gas?.maxFeePerGas) {
2459
2289
  txRequest.maxFeePerGas = gas.maxFeePerGas;
2460
2290
  }
@@ -4166,8 +3996,7 @@ async function executeDeployBatch(data, context, gas, logger = noopLogger) {
4166
3996
  environmentConfig: context.environmentConfig,
4167
3997
  executions: data.executions,
4168
3998
  pendingMessage,
4169
- gas,
4170
- authorizationList: data.authorizationList
3999
+ gas
4171
4000
  },
4172
4001
  logger
4173
4002
  );
@@ -4278,8 +4107,7 @@ async function executeUpgradeBatch(data, context, gas, logger = noopLogger) {
4278
4107
  environmentConfig: context.environmentConfig,
4279
4108
  executions: data.executions,
4280
4109
  pendingMessage,
4281
- gas,
4282
- authorizationList: data.authorizationList
4110
+ gas
4283
4111
  },
4284
4112
  logger
4285
4113
  );
@@ -4487,8 +4315,126 @@ async function calculatePermissionSignature(options) {
4487
4315
  return { signature, digest };
4488
4316
  }
4489
4317
 
4318
+ // src/client/common/auth/session.ts
4319
+ var SessionError = class extends Error {
4320
+ constructor(message, code, statusCode) {
4321
+ super(message);
4322
+ this.code = code;
4323
+ this.statusCode = statusCode;
4324
+ this.name = "SessionError";
4325
+ }
4326
+ };
4327
+ function stripHexPrefix2(hex) {
4328
+ return hex.startsWith("0x") ? hex.slice(2) : hex;
4329
+ }
4330
+ async function parseErrorResponse(response) {
4331
+ try {
4332
+ const data = await response.json();
4333
+ return data.error || response.statusText;
4334
+ } catch {
4335
+ return response.statusText;
4336
+ }
4337
+ }
4338
+ async function loginToComputeApi(config, request) {
4339
+ let response;
4340
+ try {
4341
+ response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
4342
+ method: "POST",
4343
+ credentials: "include",
4344
+ // Include cookies for session management
4345
+ headers: {
4346
+ "Content-Type": "application/json"
4347
+ },
4348
+ body: JSON.stringify({
4349
+ message: request.message,
4350
+ signature: stripHexPrefix2(request.signature)
4351
+ })
4352
+ });
4353
+ } catch (error) {
4354
+ throw new SessionError(
4355
+ `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
4356
+ "NETWORK_ERROR"
4357
+ );
4358
+ }
4359
+ if (!response.ok) {
4360
+ const errorMessage = await parseErrorResponse(response);
4361
+ const status = response.status;
4362
+ if (status === 400) {
4363
+ if (errorMessage.toLowerCase().includes("siwe")) {
4364
+ throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
4365
+ }
4366
+ throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
4367
+ }
4368
+ if (status === 401) {
4369
+ throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
4370
+ }
4371
+ throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
4372
+ }
4373
+ const data = await response.json();
4374
+ return {
4375
+ success: data.success,
4376
+ address: data.address
4377
+ };
4378
+ }
4379
+ async function getComputeApiSession(config) {
4380
+ let response;
4381
+ try {
4382
+ response = await fetch(`${config.baseUrl}/auth/session`, {
4383
+ method: "GET",
4384
+ credentials: "include",
4385
+ // Include cookies for session management
4386
+ headers: {
4387
+ "Content-Type": "application/json"
4388
+ }
4389
+ });
4390
+ } catch {
4391
+ return {
4392
+ authenticated: false
4393
+ };
4394
+ }
4395
+ if (response.status === 401) {
4396
+ return {
4397
+ authenticated: false
4398
+ };
4399
+ }
4400
+ if (!response.ok) {
4401
+ const errorMessage = await parseErrorResponse(response);
4402
+ throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
4403
+ }
4404
+ const data = await response.json();
4405
+ return {
4406
+ authenticated: data.authenticated,
4407
+ address: data.address,
4408
+ chainId: data.chain_id
4409
+ };
4410
+ }
4411
+ async function logoutFromComputeApi(config) {
4412
+ let response;
4413
+ try {
4414
+ response = await fetch(`${config.baseUrl}/auth/logout`, {
4415
+ method: "POST",
4416
+ credentials: "include",
4417
+ // Include cookies for session management
4418
+ headers: {
4419
+ "Content-Type": "application/json"
4420
+ }
4421
+ });
4422
+ } catch (error) {
4423
+ throw new SessionError(
4424
+ `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
4425
+ "NETWORK_ERROR"
4426
+ );
4427
+ }
4428
+ if (response.status === 401) {
4429
+ return;
4430
+ }
4431
+ if (!response.ok) {
4432
+ const errorMessage = await parseErrorResponse(response);
4433
+ throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
4434
+ }
4435
+ }
4436
+
4490
4437
  // src/client/common/utils/userapi.ts
4491
- init_session();
4492
4438
  function isJsonObject(value) {
4493
4439
  return typeof value === "object" && value !== null && !Array.isArray(value);
4494
4440
  }
@@ -4505,7 +4451,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4505
4451
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4506
4452
  var CanUpdateAppProfilePermission = "0x036fef61";
4507
4453
  function getDefaultClientId() {
4508
- const version = true ? "0.3.0-dev.0" : "0.0.0";
4454
+ const version = true ? "0.3.1-dev" : "0.0.0";
4509
4455
  return `ecloud-sdk/v${version}`;
4510
4456
  }
4511
4457
  var UserApiClient = class {
@@ -5448,24 +5394,16 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
5448
5394
  },
5449
5395
  logger
5450
5396
  );
5451
- logger.debug("Checking delegation status...");
5452
- const authorizationList = await createAuthorizationList({
5453
- walletClient: batch.walletClient,
5454
- publicClient: batch.publicClient,
5455
- environmentConfig: batch.environmentConfig
5456
- });
5457
5397
  logger.debug("Estimating gas...");
5458
5398
  const gasEstimate = await estimateBatchGas({
5459
5399
  publicClient: batch.publicClient,
5460
5400
  account: batch.walletClient.account.address,
5461
- executions: batch.executions,
5462
- authorizationList
5401
+ executions: batch.executions
5463
5402
  });
5464
5403
  const data = {
5465
5404
  appId: batch.appId,
5466
5405
  salt: batch.salt,
5467
- executions: batch.executions,
5468
- authorizationList
5406
+ executions: batch.executions
5469
5407
  };
5470
5408
  return {
5471
5409
  prepared: {
@@ -5694,24 +5632,16 @@ async function prepareDeploy(options, logger = defaultLogger) {
5694
5632
  },
5695
5633
  logger
5696
5634
  );
5697
- logger.debug("Checking delegation status...");
5698
- const authorizationList = await createAuthorizationList({
5699
- walletClient: batch.walletClient,
5700
- publicClient: batch.publicClient,
5701
- environmentConfig: batch.environmentConfig
5702
- });
5703
5635
  logger.debug("Estimating gas...");
5704
5636
  const gasEstimate = await estimateBatchGas({
5705
5637
  publicClient: batch.publicClient,
5706
5638
  account: batch.walletClient.account.address,
5707
- executions: batch.executions,
5708
- authorizationList
5639
+ executions: batch.executions
5709
5640
  });
5710
5641
  const data = {
5711
5642
  appId: batch.appId,
5712
5643
  salt: batch.salt,
5713
- executions: batch.executions,
5714
- authorizationList
5644
+ executions: batch.executions
5715
5645
  };
5716
5646
  return {
5717
5647
  prepared: {
@@ -5842,23 +5772,15 @@ async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger
5842
5772
  needsPermissionChange,
5843
5773
  imageRef: options.imageRef
5844
5774
  });
5845
- logger.debug("Checking delegation status...");
5846
- const authorizationList = await createAuthorizationList({
5847
- walletClient: batch.walletClient,
5848
- publicClient: batch.publicClient,
5849
- environmentConfig: batch.environmentConfig
5850
- });
5851
5775
  logger.debug("Estimating gas...");
5852
5776
  const gasEstimate = await estimateBatchGas({
5853
5777
  publicClient: batch.publicClient,
5854
5778
  account: batch.walletClient.account.address,
5855
- executions: batch.executions,
5856
- authorizationList
5779
+ executions: batch.executions
5857
5780
  });
5858
5781
  const data = {
5859
5782
  appId: batch.appId,
5860
- executions: batch.executions,
5861
- authorizationList
5783
+ executions: batch.executions
5862
5784
  };
5863
5785
  return {
5864
5786
  prepared: {
@@ -6031,23 +5953,15 @@ async function prepareUpgrade(options, logger = defaultLogger) {
6031
5953
  needsPermissionChange,
6032
5954
  imageRef: finalImageRef
6033
5955
  });
6034
- logger.debug("Checking delegation status...");
6035
- const authorizationList = await createAuthorizationList({
6036
- walletClient: batch.walletClient,
6037
- publicClient: batch.publicClient,
6038
- environmentConfig: batch.environmentConfig
6039
- });
6040
5956
  logger.debug("Estimating gas...");
6041
5957
  const gasEstimate = await estimateBatchGas({
6042
5958
  publicClient: batch.publicClient,
6043
5959
  account: batch.walletClient.account.address,
6044
- executions: batch.executions,
6045
- authorizationList
5960
+ executions: batch.executions
6046
5961
  });
6047
5962
  const data = {
6048
5963
  appId: batch.appId,
6049
- executions: batch.executions,
6050
- authorizationList
5964
+ executions: batch.executions
6051
5965
  };
6052
5966
  return {
6053
5967
  prepared: {