@agirails/sdk 2.5.3 → 2.5.4
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/ACTPClient.d.ts +18 -0
- package/dist/ACTPClient.d.ts.map +1 -1
- package/dist/ACTPClient.js +67 -22
- package/dist/ACTPClient.js.map +1 -1
- package/dist/adapters/BasicAdapter.d.ts +12 -0
- package/dist/adapters/BasicAdapter.d.ts.map +1 -1
- package/dist/adapters/BasicAdapter.js +30 -4
- package/dist/adapters/BasicAdapter.js.map +1 -1
- package/dist/adapters/StandardAdapter.d.ts +20 -3
- package/dist/adapters/StandardAdapter.d.ts.map +1 -1
- package/dist/adapters/StandardAdapter.js +45 -11
- package/dist/adapters/StandardAdapter.js.map +1 -1
- package/dist/cli/commands/publish.js +16 -4
- package/dist/cli/commands/publish.js.map +1 -1
- package/dist/cli/commands/register.js +16 -4
- package/dist/cli/commands/register.js.map +1 -1
- package/dist/cli/commands/tx.js +31 -3
- package/dist/cli/commands/tx.js.map +1 -1
- package/dist/config/networks.d.ts +2 -2
- package/dist/config/networks.d.ts.map +1 -1
- package/dist/config/networks.js +27 -22
- package/dist/config/networks.js.map +1 -1
- package/dist/level0/request.d.ts.map +1 -1
- package/dist/level0/request.js +2 -1
- package/dist/level0/request.js.map +1 -1
- package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
- package/dist/runtime/BlockchainRuntime.js +11 -5
- package/dist/runtime/BlockchainRuntime.js.map +1 -1
- package/dist/utils/IPFSClient.d.ts +3 -1
- package/dist/utils/IPFSClient.d.ts.map +1 -1
- package/dist/utils/IPFSClient.js +27 -7
- package/dist/utils/IPFSClient.js.map +1 -1
- package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
- package/dist/wallet/AutoWalletProvider.js +52 -18
- package/dist/wallet/AutoWalletProvider.js.map +1 -1
- package/dist/wallet/SmartWalletRouter.d.ts +116 -0
- package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
- package/dist/wallet/SmartWalletRouter.js +212 -0
- package/dist/wallet/SmartWalletRouter.js.map +1 -0
- package/dist/wallet/aa/DualNonceManager.d.ts +19 -0
- package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
- package/dist/wallet/aa/DualNonceManager.js +100 -5
- package/dist/wallet/aa/DualNonceManager.js.map +1 -1
- package/package.json +3 -6
- package/src/ACTPClient.ts +0 -1579
- package/src/abi/ACTPKernel.json +0 -1356
- package/src/abi/AgentRegistry.json +0 -915
- package/src/abi/ERC20.json +0 -40
- package/src/abi/EscrowVault.json +0 -134
- package/src/abi/IdentityRegistry.json +0 -316
- package/src/adapters/AdapterRegistry.ts +0 -173
- package/src/adapters/AdapterRouter.ts +0 -416
- package/src/adapters/BaseAdapter.ts +0 -498
- package/src/adapters/BasicAdapter.ts +0 -514
- package/src/adapters/IAdapter.ts +0 -292
- package/src/adapters/StandardAdapter.ts +0 -555
- package/src/adapters/X402Adapter.ts +0 -731
- package/src/adapters/index.ts +0 -60
- package/src/builders/DeliveryProofBuilder.ts +0 -327
- package/src/builders/QuoteBuilder.ts +0 -483
- package/src/builders/index.ts +0 -17
- package/src/cli/commands/balance.ts +0 -110
- package/src/cli/commands/batch.ts +0 -487
- package/src/cli/commands/config.ts +0 -231
- package/src/cli/commands/deploy-check.ts +0 -364
- package/src/cli/commands/deploy-env.ts +0 -120
- package/src/cli/commands/diff.ts +0 -141
- package/src/cli/commands/init.ts +0 -469
- package/src/cli/commands/mint.ts +0 -116
- package/src/cli/commands/pay.ts +0 -113
- package/src/cli/commands/publish.ts +0 -475
- package/src/cli/commands/pull.ts +0 -124
- package/src/cli/commands/register.ts +0 -247
- package/src/cli/commands/simulate.ts +0 -345
- package/src/cli/commands/time.ts +0 -302
- package/src/cli/commands/tx.ts +0 -448
- package/src/cli/commands/watch.ts +0 -211
- package/src/cli/index.ts +0 -134
- package/src/cli/utils/client.ts +0 -252
- package/src/cli/utils/config.ts +0 -389
- package/src/cli/utils/output.ts +0 -465
- package/src/cli/utils/wallet.ts +0 -109
- package/src/config/agirailsmd.ts +0 -262
- package/src/config/networks.ts +0 -275
- package/src/config/pendingPublish.ts +0 -237
- package/src/config/publishPipeline.ts +0 -359
- package/src/config/syncOperations.ts +0 -279
- package/src/erc8004/ERC8004Bridge.ts +0 -462
- package/src/erc8004/ReputationReporter.ts +0 -468
- package/src/erc8004/index.ts +0 -61
- package/src/errors/index.ts +0 -427
- package/src/index.ts +0 -364
- package/src/level0/Provider.ts +0 -117
- package/src/level0/ServiceDirectory.ts +0 -131
- package/src/level0/index.ts +0 -10
- package/src/level0/provide.ts +0 -132
- package/src/level0/request.ts +0 -432
- package/src/level1/Agent.ts +0 -1426
- package/src/level1/index.ts +0 -10
- package/src/level1/pricing/PriceCalculator.ts +0 -255
- package/src/level1/pricing/PricingStrategy.ts +0 -198
- package/src/level1/types/Job.ts +0 -179
- package/src/level1/types/Options.ts +0 -291
- package/src/level1/types/index.ts +0 -8
- package/src/protocol/ACTPKernel.ts +0 -808
- package/src/protocol/AgentRegistry.ts +0 -559
- package/src/protocol/DIDManager.ts +0 -629
- package/src/protocol/DIDResolver.ts +0 -554
- package/src/protocol/EASHelper.ts +0 -378
- package/src/protocol/EscrowVault.ts +0 -255
- package/src/protocol/EventMonitor.ts +0 -204
- package/src/protocol/MessageSigner.ts +0 -510
- package/src/protocol/ProofGenerator.ts +0 -339
- package/src/protocol/QuoteBuilder.ts +0 -15
- package/src/registry/AgentRegistryClient.ts +0 -202
- package/src/runtime/BlockchainRuntime.ts +0 -1015
- package/src/runtime/IACTPRuntime.ts +0 -306
- package/src/runtime/MockRuntime.ts +0 -1298
- package/src/runtime/MockStateManager.ts +0 -577
- package/src/runtime/index.ts +0 -25
- package/src/runtime/types/MockState.ts +0 -237
- package/src/storage/ArchiveBundleBuilder.ts +0 -561
- package/src/storage/ArweaveClient.ts +0 -946
- package/src/storage/FilebaseClient.ts +0 -790
- package/src/storage/index.ts +0 -96
- package/src/storage/types.ts +0 -348
- package/src/types/adapter.ts +0 -310
- package/src/types/agent.ts +0 -79
- package/src/types/did.ts +0 -223
- package/src/types/eip712.ts +0 -175
- package/src/types/erc8004.ts +0 -293
- package/src/types/escrow.ts +0 -27
- package/src/types/index.ts +0 -17
- package/src/types/message.ts +0 -145
- package/src/types/state.ts +0 -87
- package/src/types/transaction.ts +0 -69
- package/src/types/x402.ts +0 -251
- package/src/utils/ErrorRecoveryGuide.ts +0 -676
- package/src/utils/Helpers.ts +0 -688
- package/src/utils/IPFSClient.ts +0 -368
- package/src/utils/Logger.ts +0 -484
- package/src/utils/NonceManager.ts +0 -591
- package/src/utils/RateLimiter.ts +0 -534
- package/src/utils/ReceivedNonceTracker.ts +0 -567
- package/src/utils/SDKLifecycle.ts +0 -416
- package/src/utils/SecureNonce.ts +0 -78
- package/src/utils/Semaphore.ts +0 -276
- package/src/utils/UsedAttestationTracker.ts +0 -385
- package/src/utils/canonicalJson.ts +0 -38
- package/src/utils/circuitBreaker.ts +0 -324
- package/src/utils/computeTypeHash.ts +0 -48
- package/src/utils/fsSafe.ts +0 -80
- package/src/utils/index.ts +0 -80
- package/src/utils/retry.ts +0 -364
- package/src/utils/security.ts +0 -418
- package/src/utils/validation.ts +0 -540
- package/src/wallet/AutoWalletProvider.ts +0 -299
- package/src/wallet/EOAWalletProvider.ts +0 -69
- package/src/wallet/IWalletProvider.ts +0 -135
- package/src/wallet/aa/BundlerClient.ts +0 -274
- package/src/wallet/aa/DualNonceManager.ts +0 -173
- package/src/wallet/aa/PaymasterClient.ts +0 -174
- package/src/wallet/aa/TransactionBatcher.ts +0 -353
- package/src/wallet/aa/UserOpBuilder.ts +0 -246
- package/src/wallet/aa/constants.ts +0 -60
- package/src/wallet/keystore.ts +0 -240
package/src/cli/utils/output.ts
DELETED
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Output Formatting Utilities
|
|
3
|
-
*
|
|
4
|
-
* Handles multi-mode output for human and machine consumption.
|
|
5
|
-
* Supports three output modes:
|
|
6
|
-
* - human: Colorful, formatted output for terminal users
|
|
7
|
-
* - json: Machine-readable JSON for scripting
|
|
8
|
-
* - quiet: Minimal output (just the essential value)
|
|
9
|
-
*
|
|
10
|
-
* @module cli/utils/output
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// ============================================================================
|
|
14
|
-
// Types
|
|
15
|
-
// ============================================================================
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Output mode for CLI commands
|
|
19
|
-
*/
|
|
20
|
-
export type OutputMode = 'human' | 'json' | 'quiet';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Structured error for JSON output
|
|
24
|
-
*/
|
|
25
|
-
export interface CLIError {
|
|
26
|
-
code: string;
|
|
27
|
-
message: string;
|
|
28
|
-
details?: Record<string, unknown>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Transaction display format
|
|
33
|
-
*/
|
|
34
|
-
export interface TransactionDisplay {
|
|
35
|
-
txId: string;
|
|
36
|
-
state: string;
|
|
37
|
-
requester: string;
|
|
38
|
-
provider: string;
|
|
39
|
-
amount: string;
|
|
40
|
-
deadline: string;
|
|
41
|
-
escrowId?: string | null;
|
|
42
|
-
createdAt?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// ============================================================================
|
|
46
|
-
// Color Support Detection
|
|
47
|
-
// ============================================================================
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Check if terminal supports colors
|
|
51
|
-
*/
|
|
52
|
-
function supportsColor(): boolean {
|
|
53
|
-
// Force no color in tests or CI when FORCE_COLOR not set
|
|
54
|
-
if (process.env.NO_COLOR !== undefined) return false;
|
|
55
|
-
if (process.env.FORCE_COLOR !== undefined) return true;
|
|
56
|
-
|
|
57
|
-
// Check if stdout is TTY
|
|
58
|
-
if (!process.stdout.isTTY) return false;
|
|
59
|
-
|
|
60
|
-
// Check TERM
|
|
61
|
-
const term = process.env.TERM || '';
|
|
62
|
-
if (term === 'dumb') return false;
|
|
63
|
-
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ============================================================================
|
|
68
|
-
// ANSI Color Codes (inline, no dependencies)
|
|
69
|
-
// ============================================================================
|
|
70
|
-
|
|
71
|
-
const COLORS_ENABLED = supportsColor();
|
|
72
|
-
|
|
73
|
-
const colors = {
|
|
74
|
-
reset: COLORS_ENABLED ? '\x1b[0m' : '',
|
|
75
|
-
bold: COLORS_ENABLED ? '\x1b[1m' : '',
|
|
76
|
-
dim: COLORS_ENABLED ? '\x1b[2m' : '',
|
|
77
|
-
underline: COLORS_ENABLED ? '\x1b[4m' : '',
|
|
78
|
-
|
|
79
|
-
// Foreground
|
|
80
|
-
red: COLORS_ENABLED ? '\x1b[31m' : '',
|
|
81
|
-
green: COLORS_ENABLED ? '\x1b[32m' : '',
|
|
82
|
-
yellow: COLORS_ENABLED ? '\x1b[33m' : '',
|
|
83
|
-
blue: COLORS_ENABLED ? '\x1b[34m' : '',
|
|
84
|
-
magenta: COLORS_ENABLED ? '\x1b[35m' : '',
|
|
85
|
-
cyan: COLORS_ENABLED ? '\x1b[36m' : '',
|
|
86
|
-
white: COLORS_ENABLED ? '\x1b[37m' : '',
|
|
87
|
-
gray: COLORS_ENABLED ? '\x1b[90m' : '',
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// ============================================================================
|
|
91
|
-
// Text Formatting Helpers
|
|
92
|
-
// ============================================================================
|
|
93
|
-
|
|
94
|
-
export const fmt = {
|
|
95
|
-
bold: (s: string) => `${colors.bold}${s}${colors.reset}`,
|
|
96
|
-
dim: (s: string) => `${colors.dim}${s}${colors.reset}`,
|
|
97
|
-
underline: (s: string) => `${colors.underline}${s}${colors.reset}`,
|
|
98
|
-
|
|
99
|
-
red: (s: string) => `${colors.red}${s}${colors.reset}`,
|
|
100
|
-
green: (s: string) => `${colors.green}${s}${colors.reset}`,
|
|
101
|
-
yellow: (s: string) => `${colors.yellow}${s}${colors.reset}`,
|
|
102
|
-
blue: (s: string) => `${colors.blue}${s}${colors.reset}`,
|
|
103
|
-
magenta: (s: string) => `${colors.magenta}${s}${colors.reset}`,
|
|
104
|
-
cyan: (s: string) => `${colors.cyan}${s}${colors.reset}`,
|
|
105
|
-
white: (s: string) => `${colors.white}${s}${colors.reset}`,
|
|
106
|
-
gray: (s: string) => `${colors.gray}${s}${colors.reset}`,
|
|
107
|
-
|
|
108
|
-
// Semantic formatting
|
|
109
|
-
success: (s: string) => `${colors.green}${s}${colors.reset}`,
|
|
110
|
-
error: (s: string) => `${colors.red}${s}${colors.reset}`,
|
|
111
|
-
warning: (s: string) => `${colors.yellow}${s}${colors.reset}`,
|
|
112
|
-
info: (s: string) => `${colors.cyan}${s}${colors.reset}`,
|
|
113
|
-
label: (s: string) => `${colors.gray}${s}${colors.reset}`,
|
|
114
|
-
value: (s: string) => `${colors.white}${colors.bold}${s}${colors.reset}`,
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// ============================================================================
|
|
118
|
-
// State Formatting
|
|
119
|
-
// ============================================================================
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Format transaction state with appropriate color
|
|
123
|
-
*/
|
|
124
|
-
export function formatState(state: string): string {
|
|
125
|
-
switch (state) {
|
|
126
|
-
case 'INITIATED':
|
|
127
|
-
return fmt.yellow(state);
|
|
128
|
-
case 'QUOTED':
|
|
129
|
-
return fmt.cyan(state);
|
|
130
|
-
case 'COMMITTED':
|
|
131
|
-
return fmt.blue(state);
|
|
132
|
-
case 'IN_PROGRESS':
|
|
133
|
-
return fmt.magenta(state);
|
|
134
|
-
case 'DELIVERED':
|
|
135
|
-
return fmt.green(state);
|
|
136
|
-
case 'SETTLED':
|
|
137
|
-
return fmt.green(fmt.bold(state));
|
|
138
|
-
case 'DISPUTED':
|
|
139
|
-
return fmt.red(state);
|
|
140
|
-
case 'CANCELLED':
|
|
141
|
-
return fmt.dim(state);
|
|
142
|
-
default:
|
|
143
|
-
return state;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// ============================================================================
|
|
148
|
-
// Output Class
|
|
149
|
-
// ============================================================================
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Output formatter for CLI commands
|
|
153
|
-
*
|
|
154
|
-
* Provides consistent output across all commands with support for
|
|
155
|
-
* human-readable, JSON, and quiet modes.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```typescript
|
|
159
|
-
* const output = new Output('human');
|
|
160
|
-
*
|
|
161
|
-
* // Success message
|
|
162
|
-
* output.success('Transaction created!');
|
|
163
|
-
*
|
|
164
|
-
* // Key-value output
|
|
165
|
-
* output.keyValue('Transaction ID', txId);
|
|
166
|
-
*
|
|
167
|
-
* // JSON output (in json mode, prints JSON)
|
|
168
|
-
* output.result({ txId, state: 'INITIATED' });
|
|
169
|
-
* ```
|
|
170
|
-
*/
|
|
171
|
-
export class Output {
|
|
172
|
-
public readonly mode: OutputMode;
|
|
173
|
-
|
|
174
|
-
constructor(mode: OutputMode = 'human') {
|
|
175
|
-
this.mode = mode;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ==========================================================================
|
|
179
|
-
// Basic Output Methods
|
|
180
|
-
// ==========================================================================
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Print a line (human mode only)
|
|
184
|
-
*/
|
|
185
|
-
print(message: string): void {
|
|
186
|
-
if (this.mode === 'human') {
|
|
187
|
-
console.log(message);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Print success message
|
|
193
|
-
*/
|
|
194
|
-
success(message: string): void {
|
|
195
|
-
if (this.mode === 'human') {
|
|
196
|
-
console.log(fmt.success('[+] ' + message));
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Print error message
|
|
202
|
-
*/
|
|
203
|
-
error(message: string): void {
|
|
204
|
-
if (this.mode === 'human') {
|
|
205
|
-
console.error(fmt.error('[!] ' + message));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Print warning message
|
|
211
|
-
*/
|
|
212
|
-
warning(message: string): void {
|
|
213
|
-
if (this.mode === 'human') {
|
|
214
|
-
console.warn(fmt.warning('[*] ' + message));
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Print info message
|
|
220
|
-
*/
|
|
221
|
-
info(message: string): void {
|
|
222
|
-
if (this.mode === 'human') {
|
|
223
|
-
console.log(fmt.info('[i] ' + message));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Print a blank line (human mode only)
|
|
229
|
-
*/
|
|
230
|
-
blank(): void {
|
|
231
|
-
if (this.mode === 'human') {
|
|
232
|
-
console.log('');
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// ==========================================================================
|
|
237
|
-
// Structured Output
|
|
238
|
-
// ==========================================================================
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Print a key-value pair
|
|
242
|
-
*/
|
|
243
|
-
keyValue(key: string, value: string | number | boolean): void {
|
|
244
|
-
if (this.mode === 'human') {
|
|
245
|
-
console.log(` ${fmt.label(key + ':')} ${fmt.value(String(value))}`);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Print a section header
|
|
251
|
-
*/
|
|
252
|
-
section(title: string): void {
|
|
253
|
-
if (this.mode === 'human') {
|
|
254
|
-
console.log('');
|
|
255
|
-
console.log(fmt.bold(title));
|
|
256
|
-
console.log(fmt.dim('-'.repeat(40)));
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Print a transaction in human-readable format
|
|
262
|
-
*/
|
|
263
|
-
transaction(tx: TransactionDisplay): void {
|
|
264
|
-
if (this.mode === 'human') {
|
|
265
|
-
console.log('');
|
|
266
|
-
console.log(fmt.bold('Transaction Details'));
|
|
267
|
-
console.log(fmt.dim('-'.repeat(40)));
|
|
268
|
-
console.log(` ${fmt.label('ID:')} ${fmt.value(tx.txId)}`);
|
|
269
|
-
console.log(` ${fmt.label('State:')} ${formatState(tx.state)}`);
|
|
270
|
-
console.log(` ${fmt.label('Requester:')} ${tx.requester}`);
|
|
271
|
-
console.log(` ${fmt.label('Provider:')} ${tx.provider}`);
|
|
272
|
-
console.log(` ${fmt.label('Amount:')} ${fmt.value(tx.amount)}`);
|
|
273
|
-
console.log(` ${fmt.label('Deadline:')} ${tx.deadline}`);
|
|
274
|
-
if (tx.escrowId) {
|
|
275
|
-
console.log(` ${fmt.label('Escrow ID:')} ${tx.escrowId}`);
|
|
276
|
-
}
|
|
277
|
-
if (tx.createdAt) {
|
|
278
|
-
console.log(` ${fmt.label('Created:')} ${tx.createdAt}`);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Print a table of transactions
|
|
285
|
-
*/
|
|
286
|
-
transactionTable(transactions: TransactionDisplay[]): void {
|
|
287
|
-
if (this.mode === 'human') {
|
|
288
|
-
if (transactions.length === 0) {
|
|
289
|
-
console.log(fmt.dim(' No transactions found.'));
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// Header
|
|
294
|
-
console.log('');
|
|
295
|
-
console.log(
|
|
296
|
-
fmt.bold(
|
|
297
|
-
' ID (short) State Amount Provider'
|
|
298
|
-
)
|
|
299
|
-
);
|
|
300
|
-
console.log(fmt.dim(' ' + '-'.repeat(70)));
|
|
301
|
-
|
|
302
|
-
// Rows
|
|
303
|
-
for (const tx of transactions) {
|
|
304
|
-
const shortId = tx.txId.slice(0, 10) + '...';
|
|
305
|
-
const stateFormatted = formatState(tx.state).padEnd(20);
|
|
306
|
-
const amountPadded = tx.amount.padEnd(16);
|
|
307
|
-
const providerShort = tx.provider.slice(0, 10) + '...';
|
|
308
|
-
|
|
309
|
-
console.log(` ${shortId} ${stateFormatted} ${amountPadded} ${providerShort}`);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
console.log(fmt.dim(' ' + '-'.repeat(70)));
|
|
313
|
-
console.log(fmt.dim(` ${transactions.length} transaction(s)`));
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// ==========================================================================
|
|
318
|
-
// Result Output (Mode-Aware)
|
|
319
|
-
// ==========================================================================
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Output a result object
|
|
323
|
-
*
|
|
324
|
-
* - human mode: Pretty prints with colors
|
|
325
|
-
* - json mode: Outputs JSON
|
|
326
|
-
* - quiet mode: Outputs just the primary value (first key or specified)
|
|
327
|
-
*/
|
|
328
|
-
result(
|
|
329
|
-
data: Record<string, unknown>,
|
|
330
|
-
options: { quietKey?: string } = {}
|
|
331
|
-
): void {
|
|
332
|
-
switch (this.mode) {
|
|
333
|
-
case 'json':
|
|
334
|
-
console.log(JSON.stringify(data, null, 2));
|
|
335
|
-
break;
|
|
336
|
-
|
|
337
|
-
case 'quiet': {
|
|
338
|
-
const key = options.quietKey || Object.keys(data)[0];
|
|
339
|
-
const value = data[key];
|
|
340
|
-
if (value !== undefined && value !== null) {
|
|
341
|
-
console.log(String(value));
|
|
342
|
-
}
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
case 'human':
|
|
347
|
-
default:
|
|
348
|
-
for (const [key, value] of Object.entries(data)) {
|
|
349
|
-
this.keyValue(key, value as string | number | boolean);
|
|
350
|
-
}
|
|
351
|
-
break;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Output raw value (for quiet mode piping)
|
|
357
|
-
*/
|
|
358
|
-
raw(value: string): void {
|
|
359
|
-
console.log(value);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// ==========================================================================
|
|
363
|
-
// Error Output
|
|
364
|
-
// ==========================================================================
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Output a structured error
|
|
368
|
-
*/
|
|
369
|
-
errorResult(error: CLIError): void {
|
|
370
|
-
switch (this.mode) {
|
|
371
|
-
case 'json':
|
|
372
|
-
console.error(JSON.stringify({ error }, null, 2));
|
|
373
|
-
break;
|
|
374
|
-
|
|
375
|
-
case 'quiet':
|
|
376
|
-
console.error(error.message);
|
|
377
|
-
break;
|
|
378
|
-
|
|
379
|
-
case 'human':
|
|
380
|
-
default:
|
|
381
|
-
console.error('');
|
|
382
|
-
console.error(fmt.error(`Error: ${error.message}`));
|
|
383
|
-
if (error.details) {
|
|
384
|
-
console.error(fmt.dim(JSON.stringify(error.details, null, 2)));
|
|
385
|
-
}
|
|
386
|
-
console.error(fmt.dim(`(code: ${error.code})`));
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// ==========================================================================
|
|
392
|
-
// Progress Indicators
|
|
393
|
-
// ==========================================================================
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Start a spinner (human mode only)
|
|
397
|
-
*
|
|
398
|
-
* Returns a stop function to call when done.
|
|
399
|
-
* No-op in json/quiet modes.
|
|
400
|
-
*/
|
|
401
|
-
spinner(message: string): { stop: (success?: boolean) => void } {
|
|
402
|
-
if (this.mode !== 'human') {
|
|
403
|
-
return { stop: () => {} };
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const frames = ['|', '/', '-', '\\'];
|
|
407
|
-
let i = 0;
|
|
408
|
-
|
|
409
|
-
process.stdout.write(fmt.cyan(`[${frames[0]}] ${message}`));
|
|
410
|
-
|
|
411
|
-
const interval = setInterval(() => {
|
|
412
|
-
i = (i + 1) % frames.length;
|
|
413
|
-
process.stdout.write(`\r${fmt.cyan(`[${frames[i]}] ${message}`)}`);
|
|
414
|
-
}, 100);
|
|
415
|
-
|
|
416
|
-
return {
|
|
417
|
-
stop: (success = true) => {
|
|
418
|
-
clearInterval(interval);
|
|
419
|
-
const symbol = success ? fmt.green('[+]') : fmt.red('[!]');
|
|
420
|
-
process.stdout.write(`\r${symbol} ${message}\n`);
|
|
421
|
-
},
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// ============================================================================
|
|
427
|
-
// Global Output Instance
|
|
428
|
-
// ============================================================================
|
|
429
|
-
|
|
430
|
-
let globalOutput: Output = new Output('human');
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Set the global output mode
|
|
434
|
-
*/
|
|
435
|
-
export function setOutputMode(mode: OutputMode): void {
|
|
436
|
-
globalOutput = new Output(mode);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* Get the global output instance
|
|
441
|
-
*/
|
|
442
|
-
export function getOutput(): Output {
|
|
443
|
-
return globalOutput;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// ============================================================================
|
|
447
|
-
// Exit Codes
|
|
448
|
-
// ============================================================================
|
|
449
|
-
|
|
450
|
-
/**
|
|
451
|
-
* Standard exit codes for CLI commands
|
|
452
|
-
*
|
|
453
|
-
* Following Unix conventions and extending for ACTP-specific states.
|
|
454
|
-
*/
|
|
455
|
-
export const ExitCode = {
|
|
456
|
-
SUCCESS: 0,
|
|
457
|
-
ERROR: 1,
|
|
458
|
-
PENDING: 2, // Transaction in pending state
|
|
459
|
-
INVALID_INPUT: 3,
|
|
460
|
-
NOT_INITIALIZED: 4,
|
|
461
|
-
NETWORK_ERROR: 5,
|
|
462
|
-
TIMEOUT: 6,
|
|
463
|
-
} as const;
|
|
464
|
-
|
|
465
|
-
export type ExitCodeValue = (typeof ExitCode)[keyof typeof ExitCode];
|
package/src/cli/utils/wallet.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wallet Utilities — Shared wallet generation and Smart Wallet derivation.
|
|
3
|
-
*
|
|
4
|
-
* Extracted from init.ts for reuse by both `actp init` and `actp publish`.
|
|
5
|
-
*
|
|
6
|
-
* @module cli/utils/wallet
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import * as fs from 'fs';
|
|
10
|
-
import * as path from 'path';
|
|
11
|
-
import * as readline from 'readline';
|
|
12
|
-
import { Output } from './output';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Generate a new encrypted wallet keystore.
|
|
16
|
-
*
|
|
17
|
-
* - Creates a random ethers.Wallet
|
|
18
|
-
* - Encrypts with password (from ACTP_KEY_PASSWORD env or interactive prompt)
|
|
19
|
-
* - Saves to `{actpDir}/keystore.json` with 0o600 permissions
|
|
20
|
-
*
|
|
21
|
-
* @param actpDir - Path to .actp directory
|
|
22
|
-
* @param output - CLI output handler
|
|
23
|
-
* @returns The generated wallet's address
|
|
24
|
-
*/
|
|
25
|
-
export async function generateWallet(actpDir: string, output: Output): Promise<string> {
|
|
26
|
-
const { Wallet } = await import('ethers');
|
|
27
|
-
|
|
28
|
-
const wallet = Wallet.createRandom();
|
|
29
|
-
|
|
30
|
-
// Get password from env var or interactive prompt
|
|
31
|
-
let password = process.env.ACTP_KEY_PASSWORD;
|
|
32
|
-
if (!password) {
|
|
33
|
-
password = await promptPassword();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!password || password.length < 8) {
|
|
37
|
-
throw new Error(
|
|
38
|
-
'Wallet password required (minimum 8 characters).\n' +
|
|
39
|
-
'Set ACTP_KEY_PASSWORD env var or enter when prompted.'
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Encrypt with Keystore V3 (scrypt + AES-128-CTR)
|
|
44
|
-
output.info('Encrypting wallet (this takes a few seconds)...');
|
|
45
|
-
const keystore = await wallet.encrypt(password);
|
|
46
|
-
|
|
47
|
-
// Save with restrictive permissions
|
|
48
|
-
const keystorePath = path.join(actpDir, 'keystore.json');
|
|
49
|
-
fs.writeFileSync(keystorePath, keystore, { mode: 0o600 });
|
|
50
|
-
|
|
51
|
-
output.success('Key securely saved and encrypted');
|
|
52
|
-
output.info(`Address: ${wallet.address}`);
|
|
53
|
-
output.warning('Back up your password — it cannot be recovered.');
|
|
54
|
-
|
|
55
|
-
return wallet.address;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Compute the Smart Wallet address for an EOA signer.
|
|
60
|
-
* Uses CREATE2 counterfactual derivation — no deployment needed.
|
|
61
|
-
*
|
|
62
|
-
* @param eoaAddress - The EOA signer address
|
|
63
|
-
* @param mode - 'testnet' or 'mainnet'
|
|
64
|
-
* @param output - CLI output handler
|
|
65
|
-
* @returns The derived Smart Wallet address
|
|
66
|
-
*/
|
|
67
|
-
export async function computeSmartWalletInit(
|
|
68
|
-
eoaAddress: string,
|
|
69
|
-
mode: string,
|
|
70
|
-
output: Output
|
|
71
|
-
): Promise<string> {
|
|
72
|
-
const { ethers } = await import('ethers');
|
|
73
|
-
const { getNetwork } = await import('../../config/networks');
|
|
74
|
-
const { computeSmartWalletAddress } = await import('../../wallet/aa/UserOpBuilder');
|
|
75
|
-
|
|
76
|
-
const network = mode === 'testnet' ? 'base-sepolia' : 'base-mainnet';
|
|
77
|
-
const networkConfig = getNetwork(network);
|
|
78
|
-
const rpcUrl = networkConfig.rpcUrl;
|
|
79
|
-
const provider = new ethers.JsonRpcProvider(rpcUrl);
|
|
80
|
-
|
|
81
|
-
output.info('Computing Smart Wallet address...');
|
|
82
|
-
const smartWalletAddress = await computeSmartWalletAddress(eoaAddress, provider);
|
|
83
|
-
|
|
84
|
-
output.success(`Smart Wallet: ${smartWalletAddress}`);
|
|
85
|
-
|
|
86
|
-
return smartWalletAddress;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Interactive password prompt (TTY only).
|
|
91
|
-
* Returns empty string in non-TTY environments (piped/agent mode).
|
|
92
|
-
*/
|
|
93
|
-
async function promptPassword(): Promise<string> {
|
|
94
|
-
if (!process.stdin.isTTY) {
|
|
95
|
-
return '';
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const rl = readline.createInterface({
|
|
99
|
-
input: process.stdin,
|
|
100
|
-
output: process.stdout,
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
return new Promise((resolve) => {
|
|
104
|
-
rl.question('Enter password for wallet encryption (min 8 chars): ', (answer) => {
|
|
105
|
-
rl.close();
|
|
106
|
-
resolve(answer.trim());
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
}
|