@layr-labs/ecloud-sdk 0.3.0-dev → 0.3.0-dev.0
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.d.cts +1 -1
- package/dist/billing.d.ts +1 -1
- package/dist/browser.cjs +43 -27
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +43 -27
- package/dist/browser.js.map +1 -1
- package/dist/{compute-CdZxISln.d.ts → compute-BcJuIxc1.d.ts} +1 -1
- package/dist/{compute-Dstl0CA0.d.cts → compute-oD9uqLtr.d.cts} +1 -1
- package/dist/compute.cjs +111 -35
- 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 +111 -35
- package/dist/compute.js.map +1 -1
- package/dist/{helpers-Dk0zwgms.d.cts → helpers-BNGcO-VX.d.cts} +5 -2
- package/dist/{helpers-4w0Iojmm.d.ts → helpers-Cp8qGRTb.d.ts} +5 -2
- package/dist/{index-C0w92tCs.d.cts → index-5y9NG_Id.d.cts} +5 -1
- package/dist/{index-C0w92tCs.d.ts → index-5y9NG_Id.d.ts} +5 -1
- package/dist/index.cjs +111 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +111 -35
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-
|
|
2
|
-
import { Address, Hex, WalletClient, PublicClient, Chain } from 'viem';
|
|
1
|
+
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-5y9NG_Id.cjs';
|
|
2
|
+
import { Address, Hex, WalletClient, PublicClient, SignAuthorizationReturnType, Chain } from 'viem';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment configuration for different networks
|
|
@@ -825,6 +825,7 @@ interface EstimateBatchGasOptions {
|
|
|
825
825
|
publicClient: PublicClient;
|
|
826
826
|
account: Address;
|
|
827
827
|
executions: Execution[];
|
|
828
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
828
829
|
}
|
|
829
830
|
/**
|
|
830
831
|
* Estimate gas cost for a batch transaction
|
|
@@ -840,6 +841,8 @@ interface ExecuteBatchOptions {
|
|
|
840
841
|
pendingMessage: string;
|
|
841
842
|
/** Optional gas params from estimation */
|
|
842
843
|
gas?: GasEstimate;
|
|
844
|
+
/** Optional pre-created authorization list (skips internal creation if provided) */
|
|
845
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
843
846
|
}
|
|
844
847
|
/**
|
|
845
848
|
* Check if account is delegated to ERC-7702 delegator
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-
|
|
2
|
-
import { Address, Hex, WalletClient, PublicClient, Chain } from 'viem';
|
|
1
|
+
import { a6 as EnvironmentConfig, ag as SubscriptionStatus, a5 as BillingEnvironmentConfig, ae as ProductID, ai as CreateSubscriptionOptions, aj as CreateSubscriptionResponse, ar as ProductSubscriptionResponse, G as GasEstimate, ab as Logger } from './index-5y9NG_Id.js';
|
|
2
|
+
import { Address, Hex, WalletClient, PublicClient, SignAuthorizationReturnType, Chain } from 'viem';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Environment configuration for different networks
|
|
@@ -825,6 +825,7 @@ interface EstimateBatchGasOptions {
|
|
|
825
825
|
publicClient: PublicClient;
|
|
826
826
|
account: Address;
|
|
827
827
|
executions: Execution[];
|
|
828
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
828
829
|
}
|
|
829
830
|
/**
|
|
830
831
|
* Estimate gas cost for a batch transaction
|
|
@@ -840,6 +841,8 @@ interface ExecuteBatchOptions {
|
|
|
840
841
|
pendingMessage: string;
|
|
841
842
|
/** Optional gas params from estimation */
|
|
842
843
|
gas?: GasEstimate;
|
|
844
|
+
/** Optional pre-created authorization list (skips internal creation if provided) */
|
|
845
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
843
846
|
}
|
|
844
847
|
/**
|
|
845
848
|
* Check if account is delegated to ERC-7702 delegator
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicClient, Address, Hex, WalletClient } from 'viem';
|
|
1
|
+
import { PublicClient, Address, Hex, WalletClient, SignAuthorizationReturnType } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Contract interactions
|
|
@@ -503,6 +503,8 @@ interface PreparedDeployData {
|
|
|
503
503
|
value: bigint;
|
|
504
504
|
callData: Hex;
|
|
505
505
|
}>;
|
|
506
|
+
/** Pre-created authorization list for gas estimation accuracy (optional) */
|
|
507
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
506
508
|
}
|
|
507
509
|
/** Data-only batch for upgrade (clients provided by module) */
|
|
508
510
|
interface PreparedUpgradeData {
|
|
@@ -514,6 +516,8 @@ interface PreparedUpgradeData {
|
|
|
514
516
|
value: bigint;
|
|
515
517
|
callData: Hex;
|
|
516
518
|
}>;
|
|
519
|
+
/** Pre-created authorization list for gas estimation accuracy (optional) */
|
|
520
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
517
521
|
}
|
|
518
522
|
/** Prepared deployment ready for execution */
|
|
519
523
|
interface PreparedDeploy {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicClient, Address, Hex, WalletClient } from 'viem';
|
|
1
|
+
import { PublicClient, Address, Hex, WalletClient, SignAuthorizationReturnType } from 'viem';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Contract interactions
|
|
@@ -503,6 +503,8 @@ interface PreparedDeployData {
|
|
|
503
503
|
value: bigint;
|
|
504
504
|
callData: Hex;
|
|
505
505
|
}>;
|
|
506
|
+
/** Pre-created authorization list for gas estimation accuracy (optional) */
|
|
507
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
506
508
|
}
|
|
507
509
|
/** Data-only batch for upgrade (clients provided by module) */
|
|
508
510
|
interface PreparedUpgradeData {
|
|
@@ -514,6 +516,8 @@ interface PreparedUpgradeData {
|
|
|
514
516
|
value: bigint;
|
|
515
517
|
callData: Hex;
|
|
516
518
|
}>;
|
|
519
|
+
/** Pre-created authorization list for gas estimation accuracy (optional) */
|
|
520
|
+
authorizationList?: SignAuthorizationReturnType[];
|
|
517
521
|
}
|
|
518
522
|
/** Prepared deployment ready for execution */
|
|
519
523
|
interface PreparedDeploy {
|
package/dist/index.cjs
CHANGED
|
@@ -2446,7 +2446,7 @@ function encodeExecuteBatchData(executions) {
|
|
|
2446
2446
|
});
|
|
2447
2447
|
}
|
|
2448
2448
|
async function estimateBatchGas(options) {
|
|
2449
|
-
const { publicClient, account, executions } = options;
|
|
2449
|
+
const { publicClient, account, executions, authorizationList } = options;
|
|
2450
2450
|
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2451
2451
|
const [gasTipCap, block, estimatedGas] = await Promise.all([
|
|
2452
2452
|
publicClient.estimateMaxPriorityFeePerGas(),
|
|
@@ -2454,7 +2454,8 @@ async function estimateBatchGas(options) {
|
|
|
2454
2454
|
publicClient.estimateGas({
|
|
2455
2455
|
account,
|
|
2456
2456
|
to: account,
|
|
2457
|
-
data: executeBatchData
|
|
2457
|
+
data: executeBatchData,
|
|
2458
|
+
authorizationList
|
|
2458
2459
|
})
|
|
2459
2460
|
]);
|
|
2460
2461
|
const baseFee = block.baseFeePerGas ?? 0n;
|
|
@@ -2477,8 +2478,44 @@ async function checkERC7702Delegation(publicClient, account, delegatorAddress) {
|
|
|
2477
2478
|
const expectedCode = `0xef0100${delegatorAddress.slice(2)}`;
|
|
2478
2479
|
return code.toLowerCase() === expectedCode.toLowerCase();
|
|
2479
2480
|
}
|
|
2481
|
+
async function createAuthorizationList(options) {
|
|
2482
|
+
const { walletClient, publicClient, environmentConfig } = options;
|
|
2483
|
+
const account = walletClient.account;
|
|
2484
|
+
if (!account) {
|
|
2485
|
+
throw new Error("Wallet client must have an account");
|
|
2486
|
+
}
|
|
2487
|
+
const isDelegated2 = await checkERC7702Delegation(
|
|
2488
|
+
publicClient,
|
|
2489
|
+
account.address,
|
|
2490
|
+
environmentConfig.erc7702DelegatorAddress
|
|
2491
|
+
);
|
|
2492
|
+
if (isDelegated2) {
|
|
2493
|
+
return void 0;
|
|
2494
|
+
}
|
|
2495
|
+
const transactionNonce = await publicClient.getTransactionCount({
|
|
2496
|
+
address: account.address,
|
|
2497
|
+
blockTag: "pending"
|
|
2498
|
+
});
|
|
2499
|
+
const chainId = await publicClient.getChainId();
|
|
2500
|
+
const authorizationNonce = transactionNonce + 1;
|
|
2501
|
+
const signedAuthorization = await walletClient.signAuthorization({
|
|
2502
|
+
account,
|
|
2503
|
+
contractAddress: environmentConfig.erc7702DelegatorAddress,
|
|
2504
|
+
chainId,
|
|
2505
|
+
nonce: Number(authorizationNonce)
|
|
2506
|
+
});
|
|
2507
|
+
return [signedAuthorization];
|
|
2508
|
+
}
|
|
2480
2509
|
async function executeBatch(options, logger = noopLogger) {
|
|
2481
|
-
const {
|
|
2510
|
+
const {
|
|
2511
|
+
walletClient,
|
|
2512
|
+
publicClient,
|
|
2513
|
+
environmentConfig,
|
|
2514
|
+
executions,
|
|
2515
|
+
pendingMessage,
|
|
2516
|
+
gas,
|
|
2517
|
+
authorizationList: providedAuthList
|
|
2518
|
+
} = options;
|
|
2482
2519
|
const account = walletClient.account;
|
|
2483
2520
|
if (!account) {
|
|
2484
2521
|
throw new Error("Wallet client must have an account");
|
|
@@ -2488,27 +2525,29 @@ async function executeBatch(options, logger = noopLogger) {
|
|
|
2488
2525
|
throw new Error("Wallet client must have a chain");
|
|
2489
2526
|
}
|
|
2490
2527
|
const executeBatchData = encodeExecuteBatchData(executions);
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2528
|
+
let authorizationList = providedAuthList || [];
|
|
2529
|
+
if (authorizationList.length === 0) {
|
|
2530
|
+
const isDelegated2 = await checkERC7702Delegation(
|
|
2531
|
+
publicClient,
|
|
2532
|
+
account.address,
|
|
2533
|
+
environmentConfig.erc7702DelegatorAddress
|
|
2534
|
+
);
|
|
2535
|
+
if (!isDelegated2) {
|
|
2536
|
+
const transactionNonce = await publicClient.getTransactionCount({
|
|
2537
|
+
address: account.address,
|
|
2538
|
+
blockTag: "pending"
|
|
2539
|
+
});
|
|
2540
|
+
const chainId = await publicClient.getChainId();
|
|
2541
|
+
const authorizationNonce = transactionNonce + 1;
|
|
2542
|
+
logger.debug("Using wallet client signing for EIP-7702 authorization");
|
|
2543
|
+
const signedAuthorization = await walletClient.signAuthorization({
|
|
2544
|
+
account,
|
|
2545
|
+
contractAddress: environmentConfig.erc7702DelegatorAddress,
|
|
2546
|
+
chainId,
|
|
2547
|
+
nonce: Number(authorizationNonce)
|
|
2548
|
+
});
|
|
2549
|
+
authorizationList = [signedAuthorization];
|
|
2550
|
+
}
|
|
2512
2551
|
}
|
|
2513
2552
|
if (pendingMessage) {
|
|
2514
2553
|
logger.info(pendingMessage);
|
|
@@ -2523,6 +2562,9 @@ async function executeBatch(options, logger = noopLogger) {
|
|
|
2523
2562
|
if (authorizationList.length > 0) {
|
|
2524
2563
|
txRequest.authorizationList = authorizationList;
|
|
2525
2564
|
}
|
|
2565
|
+
if (gas?.gasLimit) {
|
|
2566
|
+
txRequest.gas = gas.gasLimit;
|
|
2567
|
+
}
|
|
2526
2568
|
if (gas?.maxFeePerGas) {
|
|
2527
2569
|
txRequest.maxFeePerGas = gas.maxFeePerGas;
|
|
2528
2570
|
}
|
|
@@ -4271,7 +4313,8 @@ async function executeDeployBatch(data, context, gas, logger = noopLogger) {
|
|
|
4271
4313
|
environmentConfig: context.environmentConfig,
|
|
4272
4314
|
executions: data.executions,
|
|
4273
4315
|
pendingMessage,
|
|
4274
|
-
gas
|
|
4316
|
+
gas,
|
|
4317
|
+
authorizationList: data.authorizationList
|
|
4275
4318
|
},
|
|
4276
4319
|
logger
|
|
4277
4320
|
);
|
|
@@ -4382,7 +4425,8 @@ async function executeUpgradeBatch(data, context, gas, logger = noopLogger) {
|
|
|
4382
4425
|
environmentConfig: context.environmentConfig,
|
|
4383
4426
|
executions: data.executions,
|
|
4384
4427
|
pendingMessage,
|
|
4385
|
-
gas
|
|
4428
|
+
gas,
|
|
4429
|
+
authorizationList: data.authorizationList
|
|
4386
4430
|
},
|
|
4387
4431
|
logger
|
|
4388
4432
|
);
|
|
@@ -4710,7 +4754,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
|
|
|
4710
4754
|
var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
|
|
4711
4755
|
var CanUpdateAppProfilePermission = "0x036fef61";
|
|
4712
4756
|
function getDefaultClientId() {
|
|
4713
|
-
const version = true ? "0.3.0-dev" : "0.0.0";
|
|
4757
|
+
const version = true ? "0.3.0-dev.0" : "0.0.0";
|
|
4714
4758
|
return `ecloud-sdk/v${version}`;
|
|
4715
4759
|
}
|
|
4716
4760
|
var UserApiClient = class {
|
|
@@ -6229,16 +6273,24 @@ async function prepareDeployFromVerifiableBuild(options, logger = defaultLogger)
|
|
|
6229
6273
|
},
|
|
6230
6274
|
logger
|
|
6231
6275
|
);
|
|
6276
|
+
logger.debug("Checking delegation status...");
|
|
6277
|
+
const authorizationList = await createAuthorizationList({
|
|
6278
|
+
walletClient: batch.walletClient,
|
|
6279
|
+
publicClient: batch.publicClient,
|
|
6280
|
+
environmentConfig: batch.environmentConfig
|
|
6281
|
+
});
|
|
6232
6282
|
logger.debug("Estimating gas...");
|
|
6233
6283
|
const gasEstimate = await estimateBatchGas({
|
|
6234
6284
|
publicClient: batch.publicClient,
|
|
6235
6285
|
account: batch.walletClient.account.address,
|
|
6236
|
-
executions: batch.executions
|
|
6286
|
+
executions: batch.executions,
|
|
6287
|
+
authorizationList
|
|
6237
6288
|
});
|
|
6238
6289
|
const data = {
|
|
6239
6290
|
appId: batch.appId,
|
|
6240
6291
|
salt: batch.salt,
|
|
6241
|
-
executions: batch.executions
|
|
6292
|
+
executions: batch.executions,
|
|
6293
|
+
authorizationList
|
|
6242
6294
|
};
|
|
6243
6295
|
return {
|
|
6244
6296
|
prepared: {
|
|
@@ -6467,16 +6519,24 @@ async function prepareDeploy(options, logger = defaultLogger) {
|
|
|
6467
6519
|
},
|
|
6468
6520
|
logger
|
|
6469
6521
|
);
|
|
6522
|
+
logger.debug("Checking delegation status...");
|
|
6523
|
+
const authorizationList = await createAuthorizationList({
|
|
6524
|
+
walletClient: batch.walletClient,
|
|
6525
|
+
publicClient: batch.publicClient,
|
|
6526
|
+
environmentConfig: batch.environmentConfig
|
|
6527
|
+
});
|
|
6470
6528
|
logger.debug("Estimating gas...");
|
|
6471
6529
|
const gasEstimate = await estimateBatchGas({
|
|
6472
6530
|
publicClient: batch.publicClient,
|
|
6473
6531
|
account: batch.walletClient.account.address,
|
|
6474
|
-
executions: batch.executions
|
|
6532
|
+
executions: batch.executions,
|
|
6533
|
+
authorizationList
|
|
6475
6534
|
});
|
|
6476
6535
|
const data = {
|
|
6477
6536
|
appId: batch.appId,
|
|
6478
6537
|
salt: batch.salt,
|
|
6479
|
-
executions: batch.executions
|
|
6538
|
+
executions: batch.executions,
|
|
6539
|
+
authorizationList
|
|
6480
6540
|
};
|
|
6481
6541
|
return {
|
|
6482
6542
|
prepared: {
|
|
@@ -6607,15 +6667,23 @@ async function prepareUpgradeFromVerifiableBuild(options, logger = defaultLogger
|
|
|
6607
6667
|
needsPermissionChange,
|
|
6608
6668
|
imageRef: options.imageRef
|
|
6609
6669
|
});
|
|
6670
|
+
logger.debug("Checking delegation status...");
|
|
6671
|
+
const authorizationList = await createAuthorizationList({
|
|
6672
|
+
walletClient: batch.walletClient,
|
|
6673
|
+
publicClient: batch.publicClient,
|
|
6674
|
+
environmentConfig: batch.environmentConfig
|
|
6675
|
+
});
|
|
6610
6676
|
logger.debug("Estimating gas...");
|
|
6611
6677
|
const gasEstimate = await estimateBatchGas({
|
|
6612
6678
|
publicClient: batch.publicClient,
|
|
6613
6679
|
account: batch.walletClient.account.address,
|
|
6614
|
-
executions: batch.executions
|
|
6680
|
+
executions: batch.executions,
|
|
6681
|
+
authorizationList
|
|
6615
6682
|
});
|
|
6616
6683
|
const data = {
|
|
6617
6684
|
appId: batch.appId,
|
|
6618
|
-
executions: batch.executions
|
|
6685
|
+
executions: batch.executions,
|
|
6686
|
+
authorizationList
|
|
6619
6687
|
};
|
|
6620
6688
|
return {
|
|
6621
6689
|
prepared: {
|
|
@@ -6788,15 +6856,23 @@ async function prepareUpgrade(options, logger = defaultLogger) {
|
|
|
6788
6856
|
needsPermissionChange,
|
|
6789
6857
|
imageRef: finalImageRef
|
|
6790
6858
|
});
|
|
6859
|
+
logger.debug("Checking delegation status...");
|
|
6860
|
+
const authorizationList = await createAuthorizationList({
|
|
6861
|
+
walletClient: batch.walletClient,
|
|
6862
|
+
publicClient: batch.publicClient,
|
|
6863
|
+
environmentConfig: batch.environmentConfig
|
|
6864
|
+
});
|
|
6791
6865
|
logger.debug("Estimating gas...");
|
|
6792
6866
|
const gasEstimate = await estimateBatchGas({
|
|
6793
6867
|
publicClient: batch.publicClient,
|
|
6794
6868
|
account: batch.walletClient.account.address,
|
|
6795
|
-
executions: batch.executions
|
|
6869
|
+
executions: batch.executions,
|
|
6870
|
+
authorizationList
|
|
6796
6871
|
});
|
|
6797
6872
|
const data = {
|
|
6798
6873
|
appId: batch.appId,
|
|
6799
|
-
executions: batch.executions
|
|
6874
|
+
executions: batch.executions,
|
|
6875
|
+
authorizationList
|
|
6800
6876
|
};
|
|
6801
6877
|
return {
|
|
6802
6878
|
prepared: {
|