@aastar/sdk 0.16.21 → 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 +26 -13
- package/dist/utils/userOp.d.ts +11 -0
- package/dist/utils/userOp.js +43 -2
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -16,16 +16,16 @@ AAstar SDK 提供了一套完整的工具集用于交互 AAstar 协议。它采
|
|
|
16
16
|
|
|
17
17
|
### Core Modules | 核心模块
|
|
18
18
|
|
|
19
|
-
- **[`@aastar/community`](
|
|
20
|
-
- **[`@aastar/operator`](
|
|
21
|
-
- **[`@aastar/enduser`](
|
|
22
|
-
- **[`@aastar/analytics`](
|
|
23
|
-
- **[`@aastar/tokens`](
|
|
24
|
-
- **[`@aastar/identity`](
|
|
25
|
-
- **[`@aastar/account`](
|
|
26
|
-
- **[`@aastar/core`](
|
|
27
|
-
- **[`@aastar/paymaster`](
|
|
28
|
-
- **[`@aastar/dapp`](
|
|
19
|
+
- **[`@aastar/community`](https://docs.aastar.io/api/@aastar/community)**: Launch & manage DAOs. (启动和管理 DAO)
|
|
20
|
+
- **[`@aastar/operator`](https://docs.aastar.io/api/@aastar/operator)**: Run Paymasters & earn rewards. (运行 Paymaster 并赚取收益)
|
|
21
|
+
- **[`@aastar/enduser`](https://docs.aastar.io/api/@aastar/enduser)**: Join communities & enjoy gasless txs. (加入社区并享受免 Gas 交易)
|
|
22
|
+
- **[`@aastar/analytics`](https://docs.aastar.io/api/@aastar/analytics)**: Monitor ecosystem data. (监控生态系统数据)
|
|
23
|
+
- **[`@aastar/tokens`](https://docs.aastar.io/api/@aastar/tokens)**: GToken & XPNTs finance tools. (GToken 和 XPNTs 金融工具)
|
|
24
|
+
- **[`@aastar/identity`](https://docs.aastar.io/api/@aastar/identity)**: Reputation & SBT management. (声誉和 SBT 管理)
|
|
25
|
+
- **[`@aastar/account`](https://docs.aastar.io/api/@aastar/account)**: Smart Account (ERC-4337) utilities. (智能账户工具)
|
|
26
|
+
- **[`@aastar/core`](https://docs.aastar.io/api/@aastar/core)**: Shared logic, Roles, and configuration. (共享逻辑、角色和配置)
|
|
27
|
+
- **[`@aastar/paymaster`](https://docs.aastar.io/api/@aastar/paymaster)**: Low-level Paymaster interactions. (低层级 Paymaster 交互)
|
|
28
|
+
- **[`@aastar/dapp`](https://docs.aastar.io/api/@aastar/dapp)**: Pre-built UI components and React hooks. (预建 UI 组件和 React hooks)
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
@@ -39,6 +39,19 @@ npm install @aastar/sdk viem
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
+
## 📚 Documentation | 文档导航
|
|
43
|
+
|
|
44
|
+
- **Docs Home**: https://docs.aastar.io/
|
|
45
|
+
- **API Reference**: https://docs.aastar.io/api/
|
|
46
|
+
- **Examples**: https://docs.aastar.io/examples/
|
|
47
|
+
- **Deployments**: https://docs.aastar.io/guide/deployments/verify.sepolia.contracts
|
|
48
|
+
- **Configuration Sync**: https://docs.aastar.io/guide/docs/Configuration_Sync
|
|
49
|
+
- **Regression Testing**: https://docs.aastar.io/guide/docs/Regression_Testing_Guide
|
|
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)
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
42
55
|
## 🚀 Usage | 使用指南
|
|
43
56
|
|
|
44
57
|
### 1. Initialize Client | 初始化客户端
|
|
@@ -160,14 +173,14 @@ npx tsx packages/analytics/src/gas-analyzer-v4.ts
|
|
|
160
173
|
- **Profit Tracking (利润追踪)**: Transparent breakdown of Protocol Revenue & Profit
|
|
161
174
|
- **L2 Simulation (L2 模拟)**: Estimate savings for migrating UserOps to Optimism
|
|
162
175
|
|
|
163
|
-
👉 **[View Full Analytics Documentation | 查看完整分析文档](
|
|
176
|
+
👉 **[View Full Analytics Documentation | 查看完整分析文档](https://docs.aastar.io/guide/packages/analytics/)**
|
|
164
177
|
|
|
165
178
|
---
|
|
166
179
|
|
|
167
180
|
## 🤝 Contributing | 贡献
|
|
168
181
|
|
|
169
|
-
We welcome contributions! Please see our
|
|
170
|
-
|
|
182
|
+
We welcome contributions! Please see our Contributing Guide for details.
|
|
183
|
+
欢迎贡献!更多详情请参考贡献指南。
|
|
171
184
|
|
|
172
185
|
---
|
|
173
186
|
|
package/dist/utils/userOp.d.ts
CHANGED
|
@@ -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
|
*/
|
package/dist/utils/userOp.js
CHANGED
|
@@ -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.
|
|
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.
|
|
18
|
-
"@aastar/dapp": "0.16.
|
|
19
|
-
"@aastar/
|
|
20
|
-
"@aastar/
|
|
21
|
-
"@aastar/
|
|
22
|
-
"@aastar/operator": "0.16.
|
|
23
|
-
"@aastar/
|
|
24
|
-
"@aastar/
|
|
25
|
-
"@aastar/
|
|
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"
|