gokite-aa-sdk 1.0.2 → 1.0.3

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
@@ -18,7 +18,7 @@ import { ethers } from 'ethers';
18
18
  const sdk = new GokiteAASDK(
19
19
  'kite_testnet',
20
20
  'https://rpc-testnet.gokite.ai',
21
- 'https://bundler-service.staging.gokite.ai/rpc/' // bundler URL
21
+ 'http://localhost:14337/rpc/' // bundler URL
22
22
  );
23
23
 
24
24
  // Owner address (from your social login SDK)
package/dist/example.d.ts CHANGED
@@ -1,47 +1,181 @@
1
1
  import { GokiteAASDK } from './gokite-aa-sdk';
2
2
  import "dotenv/config";
3
+ declare function initializeSDK(): GokiteAASDK;
3
4
  declare function handleAAError(error: any): {
4
5
  type: string;
5
6
  message: string;
6
7
  details?: any;
7
8
  };
8
9
  /**
9
- * ClientAgentVault Integration Tests
10
+ * Transfer ERC20 tokens from AA wallet to another address
11
+ * 从AA钱包转账ERC20代币到其他地址
10
12
  *
11
- * these tests show how to use the AA wallet to:
12
- * 1. deploy the ClientAgentVault proxy contract (via performCreate)
13
- * 2. configure spending rules (Spending Rules)
14
- * 3. view spending rules (read-only)
15
- * 4. withdraw funds (withdrawFunds)
16
- * 5. check token balance (read-only)
13
+ * @param eoa - User's EOA address (from Privy)
14
+ * @param to - Recipient address
15
+ * @param amount - Amount to transfer
16
+ * @param tokenAddress - Token contract address
17
+ * @param tokenDecimals - Token decimals (usually 18)
18
+ * @param signFunction - Signing function from Privy
19
+ */
20
+ export declare function transferERC20(eoa: string, to: string, amount: string, tokenAddress: string, tokenDecimals: number | undefined, signFunction: (userOpHash: string) => Promise<string>): Promise<{
21
+ success: boolean;
22
+ transactionHash: string | undefined;
23
+ message: string;
24
+ error?: undefined;
25
+ } | {
26
+ success: boolean;
27
+ error: string | undefined;
28
+ message: string;
29
+ transactionHash?: undefined;
30
+ } | {
31
+ success: boolean;
32
+ error: {
33
+ type: string;
34
+ message: string;
35
+ details?: any;
36
+ };
37
+ message: string;
38
+ transactionHash?: undefined;
39
+ }>;
40
+ /**
41
+ * 部署KitePass合约
17
42
  *
18
- * how to use:
19
- * - modify the contract addresses and parameters as needed
43
+ * @param eoa - User's EOA address
44
+ * @param signFunction - Signing function from Privy
45
+ * @returns Deployed KitePass address
20
46
  */
21
- declare function clientAgentVaultIntegrationTests(): Promise<void>;
47
+ export declare function deployKitePass(eoa: string, signFunction: (userOpHash: string) => Promise<string>): Promise<{
48
+ success: boolean;
49
+ proxyAddress?: string;
50
+ error?: any;
51
+ }>;
22
52
  /**
23
- * Test 1: Deploy ClientAgentVault Proxy via AA wallet's performCreate
53
+ * Configure spending rules for KitePass
54
+ * setSpendingRules方法会先清除现有的rules,然后设置新的rules
55
+ * 1. 新增/修改:需要先获取现有的rules,然后append新的rules,或者在现有rules的基础上修改
56
+ * 2. 删除:需要先获取现有的rules,然后删除对应的rules
57
+ *
58
+ * @param eoa - User's EOA address
59
+ * @param kitepassAddress - KitePass proxy address
60
+ * @param rules - Spending rules to configure
61
+ * @param signFunction - Signing function
62
+ */
63
+ export declare function configureSpendingRules(eoa: string, kitepassAddress: string, signFunction: (userOpHash: string) => Promise<string>): Promise<{
64
+ success: boolean;
65
+ transactionHash: string | undefined;
66
+ error?: undefined;
67
+ } | {
68
+ success: boolean;
69
+ error: string | undefined;
70
+ transactionHash?: undefined;
71
+ } | {
72
+ success: boolean;
73
+ error: {
74
+ type: string;
75
+ message: string;
76
+ details?: any;
77
+ };
78
+ transactionHash?: undefined;
79
+ }>;
80
+ /**
81
+ * View current spending rules (read-only)
82
+ * 查看当前消费规则(只读)
24
83
  */
25
- declare function DeployClientAgentVaultProxy(sdk: GokiteAASDK, eoa: string, aa: string, signFunction: any): Promise<string | null>;
84
+ export declare function viewSpendingRules(kitepassAddress: string): Promise<{
85
+ success: boolean;
86
+ rules: any;
87
+ error?: undefined;
88
+ } | {
89
+ success: boolean;
90
+ error: string;
91
+ rules?: undefined;
92
+ }>;
26
93
  /**
27
- * Test 2: Configure Spending Rules
94
+ * Withdraw funds from KitePass
95
+ * 从KitePass提取资金
28
96
  */
29
- declare function ConfigureSpendingRules(sdk: GokiteAASDK, owner: string, proxyAddress: string, signFunction: any): Promise<void>;
97
+ export declare function withdrawFunds(eoa: string, kitepassAddress: string, amount: string, tokenAddress: string | undefined, signFunction: (userOpHash: string) => Promise<string>): Promise<{
98
+ success: boolean;
99
+ transactionHash: string | undefined;
100
+ error?: undefined;
101
+ } | {
102
+ success: boolean;
103
+ error: string | undefined;
104
+ transactionHash?: undefined;
105
+ } | {
106
+ success: boolean;
107
+ error: {
108
+ type: string;
109
+ message: string;
110
+ details?: any;
111
+ };
112
+ transactionHash?: undefined;
113
+ }>;
30
114
  /**
31
- * Test 3: View Spending Rules (Read-only, no transaction sent)
115
+ * Check token balance (read-only)
116
+ * 查看代币余额(只读)
32
117
  */
33
- declare function ViewSpendingRules(sdk: GokiteAASDK, proxyAddress: string): Promise<void>;
118
+ export declare function checkTokenBalance(address: string, tokenAddress?: string): Promise<{
119
+ success: boolean;
120
+ balance: string;
121
+ symbol: any;
122
+ decimals: any;
123
+ address: string;
124
+ error?: undefined;
125
+ } | {
126
+ success: boolean;
127
+ error: string;
128
+ balance?: undefined;
129
+ symbol?: undefined;
130
+ decimals?: undefined;
131
+ address?: undefined;
132
+ }>;
133
+ export interface ServiceInfo {
134
+ serviceOwner: string;
135
+ priceModel: number;
136
+ unitPrice: number;
137
+ provider: string;
138
+ metadata: string;
139
+ name: string;
140
+ isPublic: boolean;
141
+ }
34
142
  /**
35
- * Test 4: Withdraw Funds
143
+ * Register a service in the service registry
144
+ * 在服务注册表中注册服务
145
+ *
146
+ * @param eoa - Service owner's EOA address
147
+ * @param serviceId - Service ID (bytes32)
148
+ * @param serviceInfo - Service information
149
+ * @param signFunction - Signing function
36
150
  */
37
- declare function WithdrawFunds(sdk: GokiteAASDK, owner: string, proxyAddress: string, signFunction: any): Promise<void>;
151
+ export declare function registerService(eoa: string, serviceId: string, serviceInfo: ServiceInfo, signFunction: (userOpHash: string) => Promise<string>): Promise<{
152
+ success: boolean;
153
+ transactionHash: string | undefined;
154
+ serviceId: string;
155
+ error?: undefined;
156
+ } | {
157
+ success: boolean;
158
+ error: string | undefined;
159
+ transactionHash?: undefined;
160
+ serviceId?: undefined;
161
+ } | {
162
+ success: boolean;
163
+ error: {
164
+ type: string;
165
+ message: string;
166
+ details?: any;
167
+ };
168
+ transactionHash?: undefined;
169
+ serviceId?: undefined;
170
+ }>;
38
171
  /**
39
- * Test 5: Check Token Balance (Read-only)
172
+ * Get TransparentUpgradeableProxy bytecode
173
+ * 获取透明可升级代理字节码
40
174
  */
41
- declare function CheckTokenBalance(sdk: GokiteAASDK, proxyAddress: string): Promise<void>;
175
+ declare function getTransparentProxyBytecode(): string;
42
176
  /**
43
- * Legacy example for basic AA operations
177
+ * Parse ContractCreated event from transaction logs
178
+ * 从交易日志中解析合约创建事件
44
179
  */
45
- declare function basicExample(): Promise<void>;
46
- export { clientAgentVaultIntegrationTests, basicExample, DeployClientAgentVaultProxy, ConfigureSpendingRules, ViewSpendingRules, WithdrawFunds, CheckTokenBalance, handleAAError, };
47
- export declare const example: typeof basicExample;
180
+ declare function parseContractCreatedEvent(transactionHash: string): Promise<string | null>;
181
+ export { initializeSDK, handleAAError, getTransparentProxyBytecode, parseContractCreatedEvent };