moltspay 0.2.0 → 0.2.2
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/dist/chains/index.d.mts +6 -6
- package/dist/chains/index.d.ts +6 -6
- package/dist/chains/index.js +2 -2
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/index.mjs +2 -2
- package/dist/chains/index.mjs.map +1 -1
- package/dist/cli.js +36 -36
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +36 -36
- package/dist/cli.mjs.map +1 -1
- package/dist/guide/index.d.mts +7 -7
- package/dist/guide/index.d.ts +7 -7
- package/dist/guide/index.js +50 -50
- package/dist/guide/index.js.map +1 -1
- package/dist/guide/index.mjs +50 -50
- package/dist/guide/index.mjs.map +1 -1
- package/dist/{index-CZzgdtin.d.mts → index-CyFg9s2m.d.mts} +1 -1
- package/dist/{index-CZzgdtin.d.ts → index-CyFg9s2m.d.ts} +1 -1
- package/dist/index.d.mts +89 -89
- package/dist/index.d.ts +89 -89
- package/dist/index.js +275 -275
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +275 -275
- package/dist/index.mjs.map +1 -1
- package/dist/orders/index.d.mts +13 -13
- package/dist/orders/index.d.ts +13 -13
- package/dist/orders/index.js +10 -10
- package/dist/orders/index.js.map +1 -1
- package/dist/orders/index.mjs +10 -10
- package/dist/orders/index.mjs.map +1 -1
- package/dist/permit/index.d.mts +11 -11
- package/dist/permit/index.d.ts +11 -11
- package/dist/permit/index.js +14 -14
- package/dist/permit/index.js.map +1 -1
- package/dist/permit/index.mjs +14 -14
- package/dist/permit/index.mjs.map +1 -1
- package/dist/verify/index.d.mts +4 -4
- package/dist/verify/index.d.ts +4 -4
- package/dist/verify/index.js +13 -13
- package/dist/verify/index.js.map +1 -1
- package/dist/verify/index.mjs +13 -13
- package/dist/verify/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +72 -72
- package/dist/wallet/index.d.ts +72 -72
- package/dist/wallet/index.js +48 -48
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +48 -48
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/wallet/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as ChainName, a as ChainConfig, W as WalletBalance, j as TransferResult, S as SecureWalletConfig, T as TransferParams, e as PendingTransfer, i as SecurityLimits } from '../index-
|
|
1
|
+
import { C as ChainName, a as ChainConfig, W as WalletBalance, j as TransferResult, S as SecureWalletConfig, T as TransferParams, e as PendingTransfer, i as SecurityLimits } from '../index-CyFg9s2m.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Wallet -
|
|
4
|
+
* Wallet - Basic Custody Wallet
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
6
|
+
* Features:
|
|
7
|
+
* - Query balance
|
|
8
|
+
* - Send USDC transfer
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
interface WalletConfig {
|
|
@@ -22,19 +22,19 @@ declare class Wallet {
|
|
|
22
22
|
private usdcContract;
|
|
23
23
|
constructor(config?: WalletConfig);
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Get wallet balance
|
|
26
26
|
*/
|
|
27
27
|
getBalance(): Promise<WalletBalance>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Send USDC transfer
|
|
30
30
|
*/
|
|
31
31
|
transfer(to: string, amount: number): Promise<TransferResult>;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Get ETH balance
|
|
34
34
|
*/
|
|
35
35
|
getEthBalance(): Promise<string>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Get USDC balance
|
|
38
38
|
*/
|
|
39
39
|
getUsdcBalance(): Promise<string>;
|
|
40
40
|
}
|
|
@@ -49,75 +49,75 @@ declare class SecureWallet {
|
|
|
49
49
|
private pendingTransfers;
|
|
50
50
|
constructor(config?: SecureWalletConfig);
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Get wallet address
|
|
53
53
|
*/
|
|
54
54
|
get address(): string;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Get balance
|
|
57
57
|
*/
|
|
58
58
|
getBalance(): Promise<WalletBalance>;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Secure transfer (with limit and whitelist checks)
|
|
61
61
|
*
|
|
62
|
-
*
|
|
62
|
+
* Supports two calling methods:
|
|
63
63
|
* - transfer({ to, amount, reason?, requester? })
|
|
64
64
|
* - transfer(to, amount)
|
|
65
65
|
*/
|
|
66
66
|
transfer(paramsOrTo: TransferParams | string, amountArg?: number | string): Promise<TransferResult>;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Approve pending transfer
|
|
69
69
|
*/
|
|
70
70
|
approve(requestId: string, approver: string): Promise<TransferResult>;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Reject pending transfer
|
|
73
73
|
*/
|
|
74
74
|
reject(requestId: string, rejecter: string, reason?: string): Promise<void>;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Add to whitelist
|
|
77
77
|
*/
|
|
78
78
|
addToWhitelist(address: string, addedBy: string): Promise<void>;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Remove from whitelist
|
|
81
81
|
*/
|
|
82
82
|
removeFromWhitelist(address: string, removedBy: string): Promise<void>;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* Check if address is whitelisted
|
|
85
85
|
*/
|
|
86
86
|
isWhitelisted(address: string): boolean;
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* Get pending transfers list
|
|
89
89
|
*/
|
|
90
90
|
getPendingTransfers(): PendingTransfer[];
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Get current limit config
|
|
93
93
|
*/
|
|
94
94
|
getLimits(): SecurityLimits;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* Get daily used amount
|
|
97
97
|
*/
|
|
98
98
|
getDailyUsed(): number;
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Update daily limit counter
|
|
101
101
|
*/
|
|
102
102
|
private updateDailyTotal;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* createWallet -
|
|
106
|
+
* createWallet - Create a new wallet for Agent
|
|
107
107
|
*
|
|
108
|
-
*
|
|
109
|
-
* -
|
|
110
|
-
* -
|
|
111
|
-
* -
|
|
108
|
+
* Features:
|
|
109
|
+
* - Generate new Ethereum wallet
|
|
110
|
+
* - Securely store private key (encrypted or plaintext, depending on config)
|
|
111
|
+
* - Return wallet address (never return private key)
|
|
112
112
|
*/
|
|
113
113
|
interface CreateWalletOptions {
|
|
114
|
-
/**
|
|
114
|
+
/** Storage path, default ~/.moltspay/wallet.json */
|
|
115
115
|
storagePath?: string;
|
|
116
|
-
/**
|
|
116
|
+
/** Encryption password (optional, plaintext if not provided) */
|
|
117
117
|
password?: string;
|
|
118
|
-
/**
|
|
118
|
+
/** Wallet label/name */
|
|
119
119
|
label?: string;
|
|
120
|
-
/**
|
|
120
|
+
/** Overwrite if wallet exists */
|
|
121
121
|
overwrite?: boolean;
|
|
122
122
|
}
|
|
123
123
|
interface WalletData {
|
|
@@ -125,11 +125,11 @@ interface WalletData {
|
|
|
125
125
|
label?: string;
|
|
126
126
|
createdAt: string;
|
|
127
127
|
encrypted: boolean;
|
|
128
|
-
/**
|
|
128
|
+
/** Encrypted or plaintext private key */
|
|
129
129
|
privateKey: string;
|
|
130
|
-
/**
|
|
130
|
+
/** Encryption IV */
|
|
131
131
|
iv?: string;
|
|
132
|
-
/**
|
|
132
|
+
/** Encryption salt */
|
|
133
133
|
salt?: string;
|
|
134
134
|
}
|
|
135
135
|
interface CreateWalletResult {
|
|
@@ -137,28 +137,28 @@ interface CreateWalletResult {
|
|
|
137
137
|
address?: string;
|
|
138
138
|
storagePath?: string;
|
|
139
139
|
error?: string;
|
|
140
|
-
/**
|
|
140
|
+
/** Whether newly created (false means loaded existing) */
|
|
141
141
|
isNew?: boolean;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* Create new wallet
|
|
145
145
|
*
|
|
146
146
|
* @example
|
|
147
147
|
* ```typescript
|
|
148
|
-
* //
|
|
148
|
+
* // Create unencrypted wallet
|
|
149
149
|
* const result = await createWallet();
|
|
150
|
-
* console.log('
|
|
150
|
+
* console.log('Wallet address:', result.address);
|
|
151
151
|
*
|
|
152
|
-
* //
|
|
152
|
+
* // Create encrypted wallet
|
|
153
153
|
* const result = await createWallet({ password: 'mySecurePassword' });
|
|
154
154
|
*
|
|
155
|
-
* //
|
|
155
|
+
* // Specify storage path
|
|
156
156
|
* const result = await createWallet({ storagePath: './my-wallet.json' });
|
|
157
157
|
* ```
|
|
158
158
|
*/
|
|
159
159
|
declare function createWallet(options?: CreateWalletOptions): CreateWalletResult;
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
161
|
+
* Load existing wallet
|
|
162
162
|
*/
|
|
163
163
|
declare function loadWallet(options?: {
|
|
164
164
|
storagePath?: string;
|
|
@@ -170,61 +170,61 @@ declare function loadWallet(options?: {
|
|
|
170
170
|
error?: string;
|
|
171
171
|
};
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
173
|
+
* Get wallet address (no password required)
|
|
174
174
|
*/
|
|
175
175
|
declare function getWalletAddress(storagePath?: string): string | null;
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
177
|
+
* Check if wallet exists
|
|
178
178
|
*/
|
|
179
179
|
declare function walletExists(storagePath?: string): boolean;
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
* PermitWallet -
|
|
182
|
+
* PermitWallet - Pay using Boss's Permit authorization
|
|
183
183
|
*
|
|
184
|
-
*
|
|
185
|
-
* - Agent
|
|
186
|
-
* - Agent
|
|
187
|
-
* - Agent
|
|
184
|
+
* Scenario:
|
|
185
|
+
* - Agent doesn't have USDC, but Boss gave a Permit authorization
|
|
186
|
+
* - Agent uses Permit signature + own wallet to execute transferFrom
|
|
187
|
+
* - Agent only needs small amount of ETH for gas, USDC is deducted from Boss's wallet
|
|
188
188
|
*/
|
|
189
189
|
|
|
190
190
|
interface PermitData {
|
|
191
|
-
/** Boss
|
|
191
|
+
/** Boss's wallet address (USDC holder) */
|
|
192
192
|
owner: string;
|
|
193
|
-
/** Agent
|
|
193
|
+
/** Agent's wallet address (authorized spender) */
|
|
194
194
|
spender: string;
|
|
195
|
-
/**
|
|
195
|
+
/** Authorized amount (USDC, raw 6 decimal value) */
|
|
196
196
|
value: string;
|
|
197
|
-
/**
|
|
197
|
+
/** Expiration timestamp */
|
|
198
198
|
deadline: number;
|
|
199
|
-
/**
|
|
199
|
+
/** Signature v */
|
|
200
200
|
v: number;
|
|
201
|
-
/**
|
|
201
|
+
/** Signature r */
|
|
202
202
|
r: string;
|
|
203
|
-
/**
|
|
203
|
+
/** Signature s */
|
|
204
204
|
s: string;
|
|
205
205
|
}
|
|
206
206
|
interface PermitWalletConfig {
|
|
207
207
|
chain?: ChainName;
|
|
208
|
-
/** Agent
|
|
208
|
+
/** Agent's private key (for executing transactions) */
|
|
209
209
|
privateKey?: string;
|
|
210
|
-
/**
|
|
210
|
+
/** Load private key from file */
|
|
211
211
|
walletPath?: string;
|
|
212
|
-
/**
|
|
212
|
+
/** Decryption password */
|
|
213
213
|
walletPassword?: string;
|
|
214
214
|
rpcUrl?: string;
|
|
215
215
|
}
|
|
216
216
|
interface TransferWithPermitParams {
|
|
217
|
-
/**
|
|
217
|
+
/** Recipient address */
|
|
218
218
|
to: string;
|
|
219
|
-
/**
|
|
219
|
+
/** Amount (USDC) */
|
|
220
220
|
amount: number;
|
|
221
|
-
/** Boss
|
|
221
|
+
/** Boss-signed Permit data */
|
|
222
222
|
permit: PermitData;
|
|
223
223
|
}
|
|
224
224
|
interface TransferWithPermitResult extends TransferResult {
|
|
225
|
-
/** Permit
|
|
225
|
+
/** Permit transaction hash */
|
|
226
226
|
permitTxHash?: string;
|
|
227
|
-
/** Transfer
|
|
227
|
+
/** Transfer transaction hash */
|
|
228
228
|
transferTxHash?: string;
|
|
229
229
|
}
|
|
230
230
|
declare class PermitWallet {
|
|
@@ -236,21 +236,21 @@ declare class PermitWallet {
|
|
|
236
236
|
private usdcContract;
|
|
237
237
|
constructor(config?: PermitWalletConfig);
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
239
|
+
* Check if Permit is valid (current allowance)
|
|
240
240
|
*/
|
|
241
241
|
checkPermitAllowance(owner: string): Promise<string>;
|
|
242
242
|
/**
|
|
243
|
-
*
|
|
243
|
+
* Pay using Permit authorization
|
|
244
244
|
*
|
|
245
|
-
*
|
|
246
|
-
* 1.
|
|
247
|
-
* 2.
|
|
245
|
+
* Flow:
|
|
246
|
+
* 1. Call permit() to record Boss's authorization in the contract
|
|
247
|
+
* 2. Call transferFrom() to transfer from Boss's wallet to recipient
|
|
248
248
|
*
|
|
249
249
|
* @example
|
|
250
250
|
* ```typescript
|
|
251
251
|
* const wallet = new PermitWallet({ chain: 'base' });
|
|
252
252
|
*
|
|
253
|
-
* // Boss
|
|
253
|
+
* // Boss-signed permit data
|
|
254
254
|
* const permit = {
|
|
255
255
|
* owner: '0xBOSS...',
|
|
256
256
|
* spender: wallet.address,
|
|
@@ -270,16 +270,16 @@ declare class PermitWallet {
|
|
|
270
270
|
*/
|
|
271
271
|
transferWithPermit(params: TransferWithPermitParams): Promise<TransferWithPermitResult>;
|
|
272
272
|
/**
|
|
273
|
-
*
|
|
273
|
+
* Get ETH balance (for gas)
|
|
274
274
|
*/
|
|
275
275
|
getGasBalance(): Promise<string>;
|
|
276
276
|
/**
|
|
277
|
-
*
|
|
277
|
+
* Check if there's enough gas
|
|
278
278
|
*/
|
|
279
279
|
hasEnoughGas(minEth?: number): Promise<boolean>;
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
|
-
*
|
|
282
|
+
* Format Permit request message (to send to Boss)
|
|
283
283
|
*/
|
|
284
284
|
declare function formatPermitRequest(params: {
|
|
285
285
|
agentAddress: string;
|
package/dist/wallet/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as ChainName, a as ChainConfig, W as WalletBalance, j as TransferResult, S as SecureWalletConfig, T as TransferParams, e as PendingTransfer, i as SecurityLimits } from '../index-
|
|
1
|
+
import { C as ChainName, a as ChainConfig, W as WalletBalance, j as TransferResult, S as SecureWalletConfig, T as TransferParams, e as PendingTransfer, i as SecurityLimits } from '../index-CyFg9s2m.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Wallet -
|
|
4
|
+
* Wallet - Basic Custody Wallet
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* -
|
|
8
|
-
* -
|
|
6
|
+
* Features:
|
|
7
|
+
* - Query balance
|
|
8
|
+
* - Send USDC transfer
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
interface WalletConfig {
|
|
@@ -22,19 +22,19 @@ declare class Wallet {
|
|
|
22
22
|
private usdcContract;
|
|
23
23
|
constructor(config?: WalletConfig);
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Get wallet balance
|
|
26
26
|
*/
|
|
27
27
|
getBalance(): Promise<WalletBalance>;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* Send USDC transfer
|
|
30
30
|
*/
|
|
31
31
|
transfer(to: string, amount: number): Promise<TransferResult>;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
33
|
+
* Get ETH balance
|
|
34
34
|
*/
|
|
35
35
|
getEthBalance(): Promise<string>;
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Get USDC balance
|
|
38
38
|
*/
|
|
39
39
|
getUsdcBalance(): Promise<string>;
|
|
40
40
|
}
|
|
@@ -49,75 +49,75 @@ declare class SecureWallet {
|
|
|
49
49
|
private pendingTransfers;
|
|
50
50
|
constructor(config?: SecureWalletConfig);
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Get wallet address
|
|
53
53
|
*/
|
|
54
54
|
get address(): string;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Get balance
|
|
57
57
|
*/
|
|
58
58
|
getBalance(): Promise<WalletBalance>;
|
|
59
59
|
/**
|
|
60
|
-
*
|
|
60
|
+
* Secure transfer (with limit and whitelist checks)
|
|
61
61
|
*
|
|
62
|
-
*
|
|
62
|
+
* Supports two calling methods:
|
|
63
63
|
* - transfer({ to, amount, reason?, requester? })
|
|
64
64
|
* - transfer(to, amount)
|
|
65
65
|
*/
|
|
66
66
|
transfer(paramsOrTo: TransferParams | string, amountArg?: number | string): Promise<TransferResult>;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* Approve pending transfer
|
|
69
69
|
*/
|
|
70
70
|
approve(requestId: string, approver: string): Promise<TransferResult>;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Reject pending transfer
|
|
73
73
|
*/
|
|
74
74
|
reject(requestId: string, rejecter: string, reason?: string): Promise<void>;
|
|
75
75
|
/**
|
|
76
|
-
*
|
|
76
|
+
* Add to whitelist
|
|
77
77
|
*/
|
|
78
78
|
addToWhitelist(address: string, addedBy: string): Promise<void>;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* Remove from whitelist
|
|
81
81
|
*/
|
|
82
82
|
removeFromWhitelist(address: string, removedBy: string): Promise<void>;
|
|
83
83
|
/**
|
|
84
|
-
*
|
|
84
|
+
* Check if address is whitelisted
|
|
85
85
|
*/
|
|
86
86
|
isWhitelisted(address: string): boolean;
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* Get pending transfers list
|
|
89
89
|
*/
|
|
90
90
|
getPendingTransfers(): PendingTransfer[];
|
|
91
91
|
/**
|
|
92
|
-
*
|
|
92
|
+
* Get current limit config
|
|
93
93
|
*/
|
|
94
94
|
getLimits(): SecurityLimits;
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* Get daily used amount
|
|
97
97
|
*/
|
|
98
98
|
getDailyUsed(): number;
|
|
99
99
|
/**
|
|
100
|
-
*
|
|
100
|
+
* Update daily limit counter
|
|
101
101
|
*/
|
|
102
102
|
private updateDailyTotal;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
|
-
* createWallet -
|
|
106
|
+
* createWallet - Create a new wallet for Agent
|
|
107
107
|
*
|
|
108
|
-
*
|
|
109
|
-
* -
|
|
110
|
-
* -
|
|
111
|
-
* -
|
|
108
|
+
* Features:
|
|
109
|
+
* - Generate new Ethereum wallet
|
|
110
|
+
* - Securely store private key (encrypted or plaintext, depending on config)
|
|
111
|
+
* - Return wallet address (never return private key)
|
|
112
112
|
*/
|
|
113
113
|
interface CreateWalletOptions {
|
|
114
|
-
/**
|
|
114
|
+
/** Storage path, default ~/.moltspay/wallet.json */
|
|
115
115
|
storagePath?: string;
|
|
116
|
-
/**
|
|
116
|
+
/** Encryption password (optional, plaintext if not provided) */
|
|
117
117
|
password?: string;
|
|
118
|
-
/**
|
|
118
|
+
/** Wallet label/name */
|
|
119
119
|
label?: string;
|
|
120
|
-
/**
|
|
120
|
+
/** Overwrite if wallet exists */
|
|
121
121
|
overwrite?: boolean;
|
|
122
122
|
}
|
|
123
123
|
interface WalletData {
|
|
@@ -125,11 +125,11 @@ interface WalletData {
|
|
|
125
125
|
label?: string;
|
|
126
126
|
createdAt: string;
|
|
127
127
|
encrypted: boolean;
|
|
128
|
-
/**
|
|
128
|
+
/** Encrypted or plaintext private key */
|
|
129
129
|
privateKey: string;
|
|
130
|
-
/**
|
|
130
|
+
/** Encryption IV */
|
|
131
131
|
iv?: string;
|
|
132
|
-
/**
|
|
132
|
+
/** Encryption salt */
|
|
133
133
|
salt?: string;
|
|
134
134
|
}
|
|
135
135
|
interface CreateWalletResult {
|
|
@@ -137,28 +137,28 @@ interface CreateWalletResult {
|
|
|
137
137
|
address?: string;
|
|
138
138
|
storagePath?: string;
|
|
139
139
|
error?: string;
|
|
140
|
-
/**
|
|
140
|
+
/** Whether newly created (false means loaded existing) */
|
|
141
141
|
isNew?: boolean;
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
|
-
*
|
|
144
|
+
* Create new wallet
|
|
145
145
|
*
|
|
146
146
|
* @example
|
|
147
147
|
* ```typescript
|
|
148
|
-
* //
|
|
148
|
+
* // Create unencrypted wallet
|
|
149
149
|
* const result = await createWallet();
|
|
150
|
-
* console.log('
|
|
150
|
+
* console.log('Wallet address:', result.address);
|
|
151
151
|
*
|
|
152
|
-
* //
|
|
152
|
+
* // Create encrypted wallet
|
|
153
153
|
* const result = await createWallet({ password: 'mySecurePassword' });
|
|
154
154
|
*
|
|
155
|
-
* //
|
|
155
|
+
* // Specify storage path
|
|
156
156
|
* const result = await createWallet({ storagePath: './my-wallet.json' });
|
|
157
157
|
* ```
|
|
158
158
|
*/
|
|
159
159
|
declare function createWallet(options?: CreateWalletOptions): CreateWalletResult;
|
|
160
160
|
/**
|
|
161
|
-
*
|
|
161
|
+
* Load existing wallet
|
|
162
162
|
*/
|
|
163
163
|
declare function loadWallet(options?: {
|
|
164
164
|
storagePath?: string;
|
|
@@ -170,61 +170,61 @@ declare function loadWallet(options?: {
|
|
|
170
170
|
error?: string;
|
|
171
171
|
};
|
|
172
172
|
/**
|
|
173
|
-
*
|
|
173
|
+
* Get wallet address (no password required)
|
|
174
174
|
*/
|
|
175
175
|
declare function getWalletAddress(storagePath?: string): string | null;
|
|
176
176
|
/**
|
|
177
|
-
*
|
|
177
|
+
* Check if wallet exists
|
|
178
178
|
*/
|
|
179
179
|
declare function walletExists(storagePath?: string): boolean;
|
|
180
180
|
|
|
181
181
|
/**
|
|
182
|
-
* PermitWallet -
|
|
182
|
+
* PermitWallet - Pay using Boss's Permit authorization
|
|
183
183
|
*
|
|
184
|
-
*
|
|
185
|
-
* - Agent
|
|
186
|
-
* - Agent
|
|
187
|
-
* - Agent
|
|
184
|
+
* Scenario:
|
|
185
|
+
* - Agent doesn't have USDC, but Boss gave a Permit authorization
|
|
186
|
+
* - Agent uses Permit signature + own wallet to execute transferFrom
|
|
187
|
+
* - Agent only needs small amount of ETH for gas, USDC is deducted from Boss's wallet
|
|
188
188
|
*/
|
|
189
189
|
|
|
190
190
|
interface PermitData {
|
|
191
|
-
/** Boss
|
|
191
|
+
/** Boss's wallet address (USDC holder) */
|
|
192
192
|
owner: string;
|
|
193
|
-
/** Agent
|
|
193
|
+
/** Agent's wallet address (authorized spender) */
|
|
194
194
|
spender: string;
|
|
195
|
-
/**
|
|
195
|
+
/** Authorized amount (USDC, raw 6 decimal value) */
|
|
196
196
|
value: string;
|
|
197
|
-
/**
|
|
197
|
+
/** Expiration timestamp */
|
|
198
198
|
deadline: number;
|
|
199
|
-
/**
|
|
199
|
+
/** Signature v */
|
|
200
200
|
v: number;
|
|
201
|
-
/**
|
|
201
|
+
/** Signature r */
|
|
202
202
|
r: string;
|
|
203
|
-
/**
|
|
203
|
+
/** Signature s */
|
|
204
204
|
s: string;
|
|
205
205
|
}
|
|
206
206
|
interface PermitWalletConfig {
|
|
207
207
|
chain?: ChainName;
|
|
208
|
-
/** Agent
|
|
208
|
+
/** Agent's private key (for executing transactions) */
|
|
209
209
|
privateKey?: string;
|
|
210
|
-
/**
|
|
210
|
+
/** Load private key from file */
|
|
211
211
|
walletPath?: string;
|
|
212
|
-
/**
|
|
212
|
+
/** Decryption password */
|
|
213
213
|
walletPassword?: string;
|
|
214
214
|
rpcUrl?: string;
|
|
215
215
|
}
|
|
216
216
|
interface TransferWithPermitParams {
|
|
217
|
-
/**
|
|
217
|
+
/** Recipient address */
|
|
218
218
|
to: string;
|
|
219
|
-
/**
|
|
219
|
+
/** Amount (USDC) */
|
|
220
220
|
amount: number;
|
|
221
|
-
/** Boss
|
|
221
|
+
/** Boss-signed Permit data */
|
|
222
222
|
permit: PermitData;
|
|
223
223
|
}
|
|
224
224
|
interface TransferWithPermitResult extends TransferResult {
|
|
225
|
-
/** Permit
|
|
225
|
+
/** Permit transaction hash */
|
|
226
226
|
permitTxHash?: string;
|
|
227
|
-
/** Transfer
|
|
227
|
+
/** Transfer transaction hash */
|
|
228
228
|
transferTxHash?: string;
|
|
229
229
|
}
|
|
230
230
|
declare class PermitWallet {
|
|
@@ -236,21 +236,21 @@ declare class PermitWallet {
|
|
|
236
236
|
private usdcContract;
|
|
237
237
|
constructor(config?: PermitWalletConfig);
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
239
|
+
* Check if Permit is valid (current allowance)
|
|
240
240
|
*/
|
|
241
241
|
checkPermitAllowance(owner: string): Promise<string>;
|
|
242
242
|
/**
|
|
243
|
-
*
|
|
243
|
+
* Pay using Permit authorization
|
|
244
244
|
*
|
|
245
|
-
*
|
|
246
|
-
* 1.
|
|
247
|
-
* 2.
|
|
245
|
+
* Flow:
|
|
246
|
+
* 1. Call permit() to record Boss's authorization in the contract
|
|
247
|
+
* 2. Call transferFrom() to transfer from Boss's wallet to recipient
|
|
248
248
|
*
|
|
249
249
|
* @example
|
|
250
250
|
* ```typescript
|
|
251
251
|
* const wallet = new PermitWallet({ chain: 'base' });
|
|
252
252
|
*
|
|
253
|
-
* // Boss
|
|
253
|
+
* // Boss-signed permit data
|
|
254
254
|
* const permit = {
|
|
255
255
|
* owner: '0xBOSS...',
|
|
256
256
|
* spender: wallet.address,
|
|
@@ -270,16 +270,16 @@ declare class PermitWallet {
|
|
|
270
270
|
*/
|
|
271
271
|
transferWithPermit(params: TransferWithPermitParams): Promise<TransferWithPermitResult>;
|
|
272
272
|
/**
|
|
273
|
-
*
|
|
273
|
+
* Get ETH balance (for gas)
|
|
274
274
|
*/
|
|
275
275
|
getGasBalance(): Promise<string>;
|
|
276
276
|
/**
|
|
277
|
-
*
|
|
277
|
+
* Check if there's enough gas
|
|
278
278
|
*/
|
|
279
279
|
hasEnoughGas(minEth?: number): Promise<boolean>;
|
|
280
280
|
}
|
|
281
281
|
/**
|
|
282
|
-
*
|
|
282
|
+
* Format Permit request message (to send to Boss)
|
|
283
283
|
*/
|
|
284
284
|
declare function formatPermitRequest(params: {
|
|
285
285
|
agentAddress: string;
|