@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,3 +1,3 @@
1
- export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-oD9uqLtr.cjs';
1
+ export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-Bpjb3hYD.cjs';
2
2
  import 'viem';
3
- import './index-5y9NG_Id.cjs';
3
+ import './index-DeQzn_yM.cjs';
package/dist/compute.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-BcJuIxc1.js';
1
+ export { A as AppModule, j as AppModuleConfig, C as ComputeModule, d as ComputeModuleConfig, i as createAppModule, b as createComputeModule, e as encodeStartAppData, f as encodeStopAppData, h as encodeTerminateAppData } from './compute-BYhSs8en.js';
2
2
  import 'viem';
3
- import './index-5y9NG_Id.js';
3
+ import './index-DeQzn_yM.js';
package/dist/compute.js CHANGED
@@ -1,133 +1,3 @@
1
- var __getOwnPropNames = Object.getOwnPropertyNames;
2
- var __esm = (fn, res) => function __init() {
3
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
4
- };
5
-
6
- // src/client/common/auth/session.ts
7
- function stripHexPrefix2(hex) {
8
- return hex.startsWith("0x") ? hex.slice(2) : hex;
9
- }
10
- async function parseErrorResponse(response) {
11
- try {
12
- const data = await response.json();
13
- return data.error || response.statusText;
14
- } catch {
15
- return response.statusText;
16
- }
17
- }
18
- async function loginToComputeApi(config, request) {
19
- let response;
20
- try {
21
- response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
22
- method: "POST",
23
- credentials: "include",
24
- // Include cookies for session management
25
- headers: {
26
- "Content-Type": "application/json"
27
- },
28
- body: JSON.stringify({
29
- message: request.message,
30
- signature: stripHexPrefix2(request.signature)
31
- })
32
- });
33
- } catch (error) {
34
- throw new SessionError(
35
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
36
- "NETWORK_ERROR"
37
- );
38
- }
39
- if (!response.ok) {
40
- const errorMessage = await parseErrorResponse(response);
41
- const status = response.status;
42
- if (status === 400) {
43
- if (errorMessage.toLowerCase().includes("siwe")) {
44
- throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
45
- }
46
- throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
47
- }
48
- if (status === 401) {
49
- throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
50
- }
51
- throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
52
- }
53
- const data = await response.json();
54
- return {
55
- success: data.success,
56
- address: data.address
57
- };
58
- }
59
- async function getComputeApiSession(config) {
60
- let response;
61
- try {
62
- response = await fetch(`${config.baseUrl}/auth/session`, {
63
- method: "GET",
64
- credentials: "include",
65
- // Include cookies for session management
66
- headers: {
67
- "Content-Type": "application/json"
68
- }
69
- });
70
- } catch {
71
- return {
72
- authenticated: false
73
- };
74
- }
75
- if (response.status === 401) {
76
- return {
77
- authenticated: false
78
- };
79
- }
80
- if (!response.ok) {
81
- const errorMessage = await parseErrorResponse(response);
82
- throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
83
- }
84
- const data = await response.json();
85
- return {
86
- authenticated: data.authenticated,
87
- address: data.address,
88
- chainId: data.chain_id
89
- };
90
- }
91
- async function logoutFromComputeApi(config) {
92
- let response;
93
- try {
94
- response = await fetch(`${config.baseUrl}/auth/logout`, {
95
- method: "POST",
96
- credentials: "include",
97
- // Include cookies for session management
98
- headers: {
99
- "Content-Type": "application/json"
100
- }
101
- });
102
- } catch (error) {
103
- throw new SessionError(
104
- `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
105
- "NETWORK_ERROR"
106
- );
107
- }
108
- if (response.status === 401) {
109
- return;
110
- }
111
- if (!response.ok) {
112
- const errorMessage = await parseErrorResponse(response);
113
- throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
114
- }
115
- }
116
- var SessionError;
117
- var init_session = __esm({
118
- "src/client/common/auth/session.ts"() {
119
- "use strict";
120
- SessionError = class extends Error {
121
- constructor(message, code, statusCode) {
122
- super(message);
123
- this.code = code;
124
- this.statusCode = statusCode;
125
- this.name = "SessionError";
126
- }
127
- };
128
- }
129
- });
130
-
131
1
  // src/client/modules/compute/app/index.ts
132
2
  import { parseAbi as parseAbi2, encodeFunctionData as encodeFunctionData3 } from "viem";
133
3
 
@@ -2297,7 +2167,7 @@ function encodeExecuteBatchData(executions) {
2297
2167
  });
2298
2168
  }
2299
2169
  async function estimateBatchGas(options) {
2300
- const { publicClient, account, executions, authorizationList } = options;
2170
+ const { publicClient, account, executions } = options;
2301
2171
  const executeBatchData = encodeExecuteBatchData(executions);
2302
2172
  const [gasTipCap, block, estimatedGas] = await Promise.all([
2303
2173
  publicClient.estimateMaxPriorityFeePerGas(),
@@ -2305,8 +2175,7 @@ async function estimateBatchGas(options) {
2305
2175
  publicClient.estimateGas({
2306
2176
  account,
2307
2177
  to: account,
2308
- data: executeBatchData,
2309
- authorizationList
2178
+ data: executeBatchData
2310
2179
  })
2311
2180
  ]);
2312
2181
  const baseFee = block.baseFeePerGas ?? 0n;
@@ -2329,44 +2198,8 @@ async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
2329
2198
  const expectedCode = `0xef0100${delegatorAddress.slice(2)}`;
2330
2199
  return code.toLowerCase() === expectedCode.toLowerCase();
2331
2200
  }
2332
- async function createAuthorizationList(options) {
2333
- const { walletClient, publicClient, environmentConfig } = options;
2334
- const account = walletClient.account;
2335
- if (!account) {
2336
- throw new Error("Wallet client must have an account");
2337
- }
2338
- const isDelegated2 = await checkERC7702Delegation(
2339
- publicClient,
2340
- account.address,
2341
- environmentConfig.erc7702DelegatorAddress
2342
- );
2343
- if (isDelegated2) {
2344
- return void 0;
2345
- }
2346
- const transactionNonce = await publicClient.getTransactionCount({
2347
- address: account.address,
2348
- blockTag: "pending"
2349
- });
2350
- const chainId = await publicClient.getChainId();
2351
- const authorizationNonce = transactionNonce + 1;
2352
- const signedAuthorization = await walletClient.signAuthorization({
2353
- account,
2354
- contractAddress: environmentConfig.erc7702DelegatorAddress,
2355
- chainId,
2356
- nonce: Number(authorizationNonce)
2357
- });
2358
- return [signedAuthorization];
2359
- }
2360
2201
  async function executeBatch(options, logger = noopLogger) {
2361
- const {
2362
- walletClient,
2363
- publicClient,
2364
- environmentConfig,
2365
- executions,
2366
- pendingMessage,
2367
- gas,
2368
- authorizationList: providedAuthList
2369
- } = options;
2202
+ const { walletClient, publicClient, environmentConfig, executions, pendingMessage, gas } = options;
2370
2203
  const account = walletClient.account;
2371
2204
  if (!account) {
2372
2205
  throw new Error("Wallet client must have an account");
@@ -2376,29 +2209,27 @@ async function executeBatch(options, logger = noopLogger) {
2376
2209
  throw new Error("Wallet client must have a chain");
2377
2210
  }
2378
2211
  const executeBatchData = encodeExecuteBatchData(executions);
2379
- let authorizationList = providedAuthList || [];
2380
- if (authorizationList.length === 0) {
2381
- const isDelegated2 = await checkERC7702Delegation(
2382
- publicClient,
2383
- account.address,
2384
- environmentConfig.erc7702DelegatorAddress
2385
- );
2386
- if (!isDelegated2) {
2387
- const transactionNonce = await publicClient.getTransactionCount({
2388
- address: account.address,
2389
- blockTag: "pending"
2390
- });
2391
- const chainId = await publicClient.getChainId();
2392
- const authorizationNonce = transactionNonce + 1;
2393
- logger.debug("Using wallet client signing for EIP-7702 authorization");
2394
- const signedAuthorization = await walletClient.signAuthorization({
2395
- account,
2396
- contractAddress: environmentConfig.erc7702DelegatorAddress,
2397
- chainId,
2398
- nonce: Number(authorizationNonce)
2399
- });
2400
- authorizationList = [signedAuthorization];
2401
- }
2212
+ const isDelegated2 = await checkERC7702Delegation(
2213
+ publicClient,
2214
+ account.address,
2215
+ environmentConfig.erc7702DelegatorAddress
2216
+ );
2217
+ let authorizationList = [];
2218
+ if (!isDelegated2) {
2219
+ const transactionNonce = await publicClient.getTransactionCount({
2220
+ address: account.address,
2221
+ blockTag: "pending"
2222
+ });
2223
+ const chainId = await publicClient.getChainId();
2224
+ const authorizationNonce = transactionNonce + 1;
2225
+ logger.debug("Using wallet client signing for EIP-7702 authorization");
2226
+ const signedAuthorization = await walletClient.signAuthorization({
2227
+ account: account.address,
2228
+ contractAddress: environmentConfig.erc7702DelegatorAddress,
2229
+ chainId,
2230
+ nonce: Number(authorizationNonce)
2231
+ });
2232
+ authorizationList = [signedAuthorization];
2402
2233
  }
2403
2234
  if (pendingMessage) {
2404
2235
  logger.info(pendingMessage);
@@ -2413,9 +2244,6 @@ async function executeBatch(options, logger = noopLogger) {
2413
2244
  if (authorizationList.length > 0) {
2414
2245
  txRequest.authorizationList = authorizationList;
2415
2246
  }
2416
- if (gas?.gasLimit) {
2417
- txRequest.gas = gas.gasLimit;
2418
- }
2419
2247
  if (gas?.maxFeePerGas) {
2420
2248
  txRequest.maxFeePerGas = gas.maxFeePerGas;
2421
2249
  }
@@ -4127,8 +3955,7 @@ async function executeDeployBatch(data, context, gas, logger = noopLogger) {
4127
3955
  environmentConfig: context.environmentConfig,
4128
3956
  executions: data.executions,
4129
3957
  pendingMessage,
4130
- gas,
4131
- authorizationList: data.authorizationList
3958
+ gas
4132
3959
  },
4133
3960
  logger
4134
3961
  );
@@ -4239,8 +4066,7 @@ async function executeUpgradeBatch(data, context, gas, logger = noopLogger) {
4239
4066
  environmentConfig: context.environmentConfig,
4240
4067
  executions: data.executions,
4241
4068
  pendingMessage,
4242
- gas,
4243
- authorizationList: data.authorizationList
4069
+ gas
4244
4070
  },
4245
4071
  logger
4246
4072
  );
@@ -4448,8 +4274,126 @@ async function calculatePermissionSignature(options) {
4448
4274
  return { signature, digest };
4449
4275
  }
4450
4276
 
4277
+ // src/client/common/auth/session.ts
4278
+ var SessionError = class extends Error {
4279
+ constructor(message, code, statusCode) {
4280
+ super(message);
4281
+ this.code = code;
4282
+ this.statusCode = statusCode;
4283
+ this.name = "SessionError";
4284
+ }
4285
+ };
4286
+ function stripHexPrefix2(hex) {
4287
+ return hex.startsWith("0x") ? hex.slice(2) : hex;
4288
+ }
4289
+ async function parseErrorResponse(response) {
4290
+ try {
4291
+ const data = await response.json();
4292
+ return data.error || response.statusText;
4293
+ } catch {
4294
+ return response.statusText;
4295
+ }
4296
+ }
4297
+ async function loginToComputeApi(config, request) {
4298
+ let response;
4299
+ try {
4300
+ response = await fetch(`${config.baseUrl}/auth/siwe/login`, {
4301
+ method: "POST",
4302
+ credentials: "include",
4303
+ // Include cookies for session management
4304
+ headers: {
4305
+ "Content-Type": "application/json"
4306
+ },
4307
+ body: JSON.stringify({
4308
+ message: request.message,
4309
+ signature: stripHexPrefix2(request.signature)
4310
+ })
4311
+ });
4312
+ } catch (error) {
4313
+ throw new SessionError(
4314
+ `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
4315
+ "NETWORK_ERROR"
4316
+ );
4317
+ }
4318
+ if (!response.ok) {
4319
+ const errorMessage = await parseErrorResponse(response);
4320
+ const status = response.status;
4321
+ if (status === 400) {
4322
+ if (errorMessage.toLowerCase().includes("siwe")) {
4323
+ throw new SessionError(`Invalid SIWE message: ${errorMessage}`, "INVALID_MESSAGE", status);
4324
+ }
4325
+ throw new SessionError(`Bad request: ${errorMessage}`, "INVALID_MESSAGE", status);
4326
+ }
4327
+ if (status === 401) {
4328
+ throw new SessionError(`Invalid signature: ${errorMessage}`, "INVALID_SIGNATURE", status);
4329
+ }
4330
+ throw new SessionError(`Login failed: ${errorMessage}`, "UNKNOWN", status);
4331
+ }
4332
+ const data = await response.json();
4333
+ return {
4334
+ success: data.success,
4335
+ address: data.address
4336
+ };
4337
+ }
4338
+ async function getComputeApiSession(config) {
4339
+ let response;
4340
+ try {
4341
+ response = await fetch(`${config.baseUrl}/auth/session`, {
4342
+ method: "GET",
4343
+ credentials: "include",
4344
+ // Include cookies for session management
4345
+ headers: {
4346
+ "Content-Type": "application/json"
4347
+ }
4348
+ });
4349
+ } catch {
4350
+ return {
4351
+ authenticated: false
4352
+ };
4353
+ }
4354
+ if (response.status === 401) {
4355
+ return {
4356
+ authenticated: false
4357
+ };
4358
+ }
4359
+ if (!response.ok) {
4360
+ const errorMessage = await parseErrorResponse(response);
4361
+ throw new SessionError(`Failed to get session: ${errorMessage}`, "UNKNOWN", response.status);
4362
+ }
4363
+ const data = await response.json();
4364
+ return {
4365
+ authenticated: data.authenticated,
4366
+ address: data.address,
4367
+ chainId: data.chain_id
4368
+ };
4369
+ }
4370
+ async function logoutFromComputeApi(config) {
4371
+ let response;
4372
+ try {
4373
+ response = await fetch(`${config.baseUrl}/auth/logout`, {
4374
+ method: "POST",
4375
+ credentials: "include",
4376
+ // Include cookies for session management
4377
+ headers: {
4378
+ "Content-Type": "application/json"
4379
+ }
4380
+ });
4381
+ } catch (error) {
4382
+ throw new SessionError(
4383
+ `Network error connecting to ${config.baseUrl}: ${error instanceof Error ? error.message : String(error)}`,
4384
+ "NETWORK_ERROR"
4385
+ );
4386
+ }
4387
+ if (response.status === 401) {
4388
+ return;
4389
+ }
4390
+ if (!response.ok) {
4391
+ const errorMessage = await parseErrorResponse(response);
4392
+ throw new SessionError(`Logout failed: ${errorMessage}`, "UNKNOWN", response.status);
4393
+ }
4394
+ }
4395
+
4451
4396
  // src/client/common/utils/userapi.ts
4452
- init_session();
4453
4397
  function isJsonObject(value) {
4454
4398
  return typeof value === "object" && value !== null && !Array.isArray(value);
4455
4399
  }
@@ -4466,7 +4410,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4466
4410
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4467
4411
  var CanUpdateAppProfilePermission = "0x036fef61";
4468
4412
  function getDefaultClientId() {
4469
- const version = true ? "0.3.0-dev.0" : "0.0.0";
4413
+ const version = true ? "0.3.1-dev" : "0.0.0";
4470
4414
  return `ecloud-sdk/v${version}`;
4471
4415
  }
4472
4416
  var UserApiClient = class {
@@ -5409,24 +5353,16 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
5409
5353
  },
5410
5354
  logger
5411
5355
  );
5412
- logger.debug("Checking delegation status...");
5413
- const authorizationList = await createAuthorizationList({
5414
- walletClient: batch.walletClient,
5415
- publicClient: batch.publicClient,
5416
- environmentConfig: batch.environmentConfig
5417
- });
5418
5356
  logger.debug("Estimating gas...");
5419
5357
  const gasEstimate = await estimateBatchGas({
5420
5358
  publicClient: batch.publicClient,
5421
5359
  account: batch.walletClient.account.address,
5422
- executions: batch.executions,
5423
- authorizationList
5360
+ executions: batch.executions
5424
5361
  });
5425
5362
  const data = {
5426
5363
  appId: batch.appId,
5427
5364
  salt: batch.salt,
5428
- executions: batch.executions,
5429
- authorizationList
5365
+ executions: batch.executions
5430
5366
  };
5431
5367
  return {
5432
5368
  prepared: {
@@ -5655,24 +5591,16 @@ async function prepareDeploy(options, logger = defaultLogger) {
5655
5591
  },
5656
5592
  logger
5657
5593
  );
5658
- logger.debug("Checking delegation status...");
5659
- const authorizationList = await createAuthorizationList({
5660
- walletClient: batch.walletClient,
5661
- publicClient: batch.publicClient,
5662
- environmentConfig: batch.environmentConfig
5663
- });
5664
5594
  logger.debug("Estimating gas...");
5665
5595
  const gasEstimate = await estimateBatchGas({
5666
5596
  publicClient: batch.publicClient,
5667
5597
  account: batch.walletClient.account.address,
5668
- executions: batch.executions,
5669
- authorizationList
5598
+ executions: batch.executions
5670
5599
  });
5671
5600
  const data = {
5672
5601
  appId: batch.appId,
5673
5602
  salt: batch.salt,
5674
- executions: batch.executions,
5675
- authorizationList
5603
+ executions: batch.executions
5676
5604
  };
5677
5605
  return {
5678
5606
  prepared: {
@@ -5803,23 +5731,15 @@ async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger
5803
5731
  needsPermissionChange,
5804
5732
  imageRef: options.imageRef
5805
5733
  });
5806
- logger.debug("Checking delegation status...");
5807
- const authorizationList = await createAuthorizationList({
5808
- walletClient: batch.walletClient,
5809
- publicClient: batch.publicClient,
5810
- environmentConfig: batch.environmentConfig
5811
- });
5812
5734
  logger.debug("Estimating gas...");
5813
5735
  const gasEstimate = await estimateBatchGas({
5814
5736
  publicClient: batch.publicClient,
5815
5737
  account: batch.walletClient.account.address,
5816
- executions: batch.executions,
5817
- authorizationList
5738
+ executions: batch.executions
5818
5739
  });
5819
5740
  const data = {
5820
5741
  appId: batch.appId,
5821
- executions: batch.executions,
5822
- authorizationList
5742
+ executions: batch.executions
5823
5743
  };
5824
5744
  return {
5825
5745
  prepared: {
@@ -5992,23 +5912,15 @@ async function prepareUpgrade(options, logger = defaultLogger) {
5992
5912
  needsPermissionChange,
5993
5913
  imageRef: finalImageRef
5994
5914
  });
5995
- logger.debug("Checking delegation status...");
5996
- const authorizationList = await createAuthorizationList({
5997
- walletClient: batch.walletClient,
5998
- publicClient: batch.publicClient,
5999
- environmentConfig: batch.environmentConfig
6000
- });
6001
5915
  logger.debug("Estimating gas...");
6002
5916
  const gasEstimate = await estimateBatchGas({
6003
5917
  publicClient: batch.publicClient,
6004
5918
  account: batch.walletClient.account.address,
6005
- executions: batch.executions,
6006
- authorizationList
5919
+ executions: batch.executions
6007
5920
  });
6008
5921
  const data = {
6009
5922
  appId: batch.appId,
6010
- executions: batch.executions,
6011
- authorizationList
5923
+ executions: batch.executions
6012
5924
  };
6013
5925
  return {
6014
5926
  prepared: {