@aastar/sdk 0.16.22 → 0.16.23

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 CHANGED
@@ -48,6 +48,7 @@ npm install @aastar/sdk viem
48
48
  - **Configuration Sync**: https://docs.aastar.io/guide/docs/Configuration_Sync
49
49
  - **Regression Testing**: https://docs.aastar.io/guide/docs/Regression_Testing_Guide
50
50
  - **Gasless Tester Guide**: https://docs.aastar.io/guide/docs/TESTER_GUIDE_GASLESS
51
+ - **Price Keeper Guide**: [docs/guide/keeper.md](../../docs/guide/keeper.md)
51
52
 
52
53
  ---
53
54
 
@@ -33,6 +33,17 @@ export declare class UserOperationBuilder {
33
33
  * Packs maxPriorityFeePerGas and maxFeePerGas into a bytes32 Hex string.
34
34
  */
35
35
  static packGasFees(maxPriorityFeePerGas: bigint, maxFeePerGas: bigint): Hex;
36
+ static estimatePreVerificationGasV07(userOp: {
37
+ sender: Address;
38
+ nonce: bigint | Hex | number | string;
39
+ initCode: Hex;
40
+ callData: Hex;
41
+ accountGasLimits: Hex;
42
+ preVerificationGas: bigint | Hex | number | string;
43
+ gasFees: Hex;
44
+ paymasterAndData: Hex;
45
+ signature: Hex;
46
+ }): bigint;
36
47
  /**
37
48
  * Packs Paymaster parameters into the v0.7 paymasterAndData format.
38
49
  */
@@ -1,4 +1,4 @@
1
- import { concat, pad } from 'viem';
1
+ import { concat, pad, encodeAbiParameters, parseAbiParameters, toBytes } from 'viem';
2
2
  export class UserOperationBuilder {
3
3
  /**
4
4
  * Packs verificationGasLimit and callGasLimit into a bytes32 Hex string.
@@ -18,6 +18,36 @@ export class UserOperationBuilder {
18
18
  pad(`0x${maxFeePerGas.toString(16)}`, { dir: 'left', size: 16 })
19
19
  ]);
20
20
  }
21
+ static estimatePreVerificationGasV07(userOp) {
22
+ const nonce = typeof userOp.nonce === 'bigint'
23
+ ? userOp.nonce
24
+ : typeof userOp.nonce === 'number'
25
+ ? BigInt(userOp.nonce)
26
+ : BigInt(userOp.nonce);
27
+ const preVerificationGas = typeof userOp.preVerificationGas === 'bigint'
28
+ ? userOp.preVerificationGas
29
+ : typeof userOp.preVerificationGas === 'number'
30
+ ? BigInt(userOp.preVerificationGas)
31
+ : BigInt(userOp.preVerificationGas);
32
+ const encoded = encodeAbiParameters(parseAbiParameters('(address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes)'), [
33
+ [
34
+ userOp.sender,
35
+ nonce,
36
+ userOp.initCode,
37
+ userOp.callData,
38
+ userOp.accountGasLimits,
39
+ preVerificationGas,
40
+ userOp.gasFees,
41
+ userOp.paymasterAndData,
42
+ userOp.signature
43
+ ]
44
+ ]);
45
+ const bytes = toBytes(encoded);
46
+ let calldataCost = 0n;
47
+ for (const b of bytes)
48
+ calldataCost += b === 0 ? 4n : 16n;
49
+ return calldataCost + 26000n;
50
+ }
21
51
  /**
22
52
  * Packs Paymaster parameters into the v0.7 paymasterAndData format.
23
53
  */
@@ -127,9 +157,20 @@ export class UserOperationBuilder {
127
157
  * @param options.paymasterPostOpGasLimit - Gas limit for paymaster postOp (default: 200000)
128
158
  */
129
159
  static toAlchemyUserOperation(userOp, options) {
160
+ const toHexStr = (val) => {
161
+ if (val === undefined || val === null)
162
+ return undefined;
163
+ if (typeof val === 'bigint')
164
+ return `0x${val.toString(16)}`;
165
+ if (typeof val === 'number')
166
+ return `0x${val.toString(16)}`;
167
+ if (typeof val === 'string' && !val.startsWith('0x'))
168
+ return `0x${val}`;
169
+ return val;
170
+ };
130
171
  const result = {
131
172
  sender: userOp.sender,
132
- nonce: userOp.nonce,
173
+ nonce: toHexStr(userOp.nonce),
133
174
  callData: userOp.callData,
134
175
  signature: userOp.signature
135
176
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aastar/sdk",
3
- "version": "0.16.22",
3
+ "version": "0.16.23",
4
4
  "description": "AAStar SDK - The all-in-one package for Mycelium Network",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -14,15 +14,15 @@
14
14
  ],
15
15
  "dependencies": {
16
16
  "viem": "2.43.3",
17
- "@aastar/core": "0.16.22",
18
- "@aastar/dapp": "0.16.22",
19
- "@aastar/identity": "0.16.22",
20
- "@aastar/account": "0.16.22",
21
- "@aastar/enduser": "0.16.22",
22
- "@aastar/paymaster": "0.16.22",
23
- "@aastar/tokens": "0.16.22",
24
- "@aastar/admin": "0.16.22",
25
- "@aastar/operator": "0.16.22"
17
+ "@aastar/core": "0.16.23",
18
+ "@aastar/dapp": "0.16.23",
19
+ "@aastar/enduser": "0.16.23",
20
+ "@aastar/paymaster": "0.16.23",
21
+ "@aastar/identity": "0.16.23",
22
+ "@aastar/operator": "0.16.23",
23
+ "@aastar/tokens": "0.16.23",
24
+ "@aastar/account": "0.16.23",
25
+ "@aastar/admin": "0.16.23"
26
26
  },
27
27
  "devDependencies": {
28
28
  "typescript": "5.7.2"