@agirails/sdk 2.5.3 → 2.5.5

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.
Files changed (169) hide show
  1. package/dist/ACTPClient.d.ts +18 -0
  2. package/dist/ACTPClient.d.ts.map +1 -1
  3. package/dist/ACTPClient.js +72 -23
  4. package/dist/ACTPClient.js.map +1 -1
  5. package/dist/adapters/BasicAdapter.d.ts +15 -0
  6. package/dist/adapters/BasicAdapter.d.ts.map +1 -1
  7. package/dist/adapters/BasicAdapter.js +33 -4
  8. package/dist/adapters/BasicAdapter.js.map +1 -1
  9. package/dist/adapters/StandardAdapter.d.ts +20 -3
  10. package/dist/adapters/StandardAdapter.d.ts.map +1 -1
  11. package/dist/adapters/StandardAdapter.js +90 -12
  12. package/dist/adapters/StandardAdapter.js.map +1 -1
  13. package/dist/cli/commands/publish.js +16 -4
  14. package/dist/cli/commands/publish.js.map +1 -1
  15. package/dist/cli/commands/register.js +16 -4
  16. package/dist/cli/commands/register.js.map +1 -1
  17. package/dist/cli/commands/tx.js +31 -3
  18. package/dist/cli/commands/tx.js.map +1 -1
  19. package/dist/config/networks.d.ts +10 -2
  20. package/dist/config/networks.d.ts.map +1 -1
  21. package/dist/config/networks.js +31 -22
  22. package/dist/config/networks.js.map +1 -1
  23. package/dist/level0/request.d.ts.map +1 -1
  24. package/dist/level0/request.js +2 -1
  25. package/dist/level0/request.js.map +1 -1
  26. package/dist/runtime/BlockchainRuntime.d.ts.map +1 -1
  27. package/dist/runtime/BlockchainRuntime.js +11 -5
  28. package/dist/runtime/BlockchainRuntime.js.map +1 -1
  29. package/dist/utils/IPFSClient.d.ts +3 -1
  30. package/dist/utils/IPFSClient.d.ts.map +1 -1
  31. package/dist/utils/IPFSClient.js +27 -7
  32. package/dist/utils/IPFSClient.js.map +1 -1
  33. package/dist/wallet/AutoWalletProvider.d.ts +11 -1
  34. package/dist/wallet/AutoWalletProvider.d.ts.map +1 -1
  35. package/dist/wallet/AutoWalletProvider.js +84 -19
  36. package/dist/wallet/AutoWalletProvider.js.map +1 -1
  37. package/dist/wallet/IWalletProvider.d.ts +34 -0
  38. package/dist/wallet/IWalletProvider.d.ts.map +1 -1
  39. package/dist/wallet/SmartWalletRouter.d.ts +128 -0
  40. package/dist/wallet/SmartWalletRouter.d.ts.map +1 -0
  41. package/dist/wallet/SmartWalletRouter.js +248 -0
  42. package/dist/wallet/SmartWalletRouter.js.map +1 -0
  43. package/dist/wallet/aa/DualNonceManager.d.ts +26 -1
  44. package/dist/wallet/aa/DualNonceManager.d.ts.map +1 -1
  45. package/dist/wallet/aa/DualNonceManager.js +140 -6
  46. package/dist/wallet/aa/DualNonceManager.js.map +1 -1
  47. package/package.json +3 -6
  48. package/src/ACTPClient.ts +0 -1579
  49. package/src/abi/ACTPKernel.json +0 -1356
  50. package/src/abi/AgentRegistry.json +0 -915
  51. package/src/abi/ERC20.json +0 -40
  52. package/src/abi/EscrowVault.json +0 -134
  53. package/src/abi/IdentityRegistry.json +0 -316
  54. package/src/adapters/AdapterRegistry.ts +0 -173
  55. package/src/adapters/AdapterRouter.ts +0 -416
  56. package/src/adapters/BaseAdapter.ts +0 -498
  57. package/src/adapters/BasicAdapter.ts +0 -514
  58. package/src/adapters/IAdapter.ts +0 -292
  59. package/src/adapters/StandardAdapter.ts +0 -555
  60. package/src/adapters/X402Adapter.ts +0 -731
  61. package/src/adapters/index.ts +0 -60
  62. package/src/builders/DeliveryProofBuilder.ts +0 -327
  63. package/src/builders/QuoteBuilder.ts +0 -483
  64. package/src/builders/index.ts +0 -17
  65. package/src/cli/commands/balance.ts +0 -110
  66. package/src/cli/commands/batch.ts +0 -487
  67. package/src/cli/commands/config.ts +0 -231
  68. package/src/cli/commands/deploy-check.ts +0 -364
  69. package/src/cli/commands/deploy-env.ts +0 -120
  70. package/src/cli/commands/diff.ts +0 -141
  71. package/src/cli/commands/init.ts +0 -469
  72. package/src/cli/commands/mint.ts +0 -116
  73. package/src/cli/commands/pay.ts +0 -113
  74. package/src/cli/commands/publish.ts +0 -475
  75. package/src/cli/commands/pull.ts +0 -124
  76. package/src/cli/commands/register.ts +0 -247
  77. package/src/cli/commands/simulate.ts +0 -345
  78. package/src/cli/commands/time.ts +0 -302
  79. package/src/cli/commands/tx.ts +0 -448
  80. package/src/cli/commands/watch.ts +0 -211
  81. package/src/cli/index.ts +0 -134
  82. package/src/cli/utils/client.ts +0 -252
  83. package/src/cli/utils/config.ts +0 -389
  84. package/src/cli/utils/output.ts +0 -465
  85. package/src/cli/utils/wallet.ts +0 -109
  86. package/src/config/agirailsmd.ts +0 -262
  87. package/src/config/networks.ts +0 -275
  88. package/src/config/pendingPublish.ts +0 -237
  89. package/src/config/publishPipeline.ts +0 -359
  90. package/src/config/syncOperations.ts +0 -279
  91. package/src/erc8004/ERC8004Bridge.ts +0 -462
  92. package/src/erc8004/ReputationReporter.ts +0 -468
  93. package/src/erc8004/index.ts +0 -61
  94. package/src/errors/index.ts +0 -427
  95. package/src/index.ts +0 -364
  96. package/src/level0/Provider.ts +0 -117
  97. package/src/level0/ServiceDirectory.ts +0 -131
  98. package/src/level0/index.ts +0 -10
  99. package/src/level0/provide.ts +0 -132
  100. package/src/level0/request.ts +0 -432
  101. package/src/level1/Agent.ts +0 -1426
  102. package/src/level1/index.ts +0 -10
  103. package/src/level1/pricing/PriceCalculator.ts +0 -255
  104. package/src/level1/pricing/PricingStrategy.ts +0 -198
  105. package/src/level1/types/Job.ts +0 -179
  106. package/src/level1/types/Options.ts +0 -291
  107. package/src/level1/types/index.ts +0 -8
  108. package/src/protocol/ACTPKernel.ts +0 -808
  109. package/src/protocol/AgentRegistry.ts +0 -559
  110. package/src/protocol/DIDManager.ts +0 -629
  111. package/src/protocol/DIDResolver.ts +0 -554
  112. package/src/protocol/EASHelper.ts +0 -378
  113. package/src/protocol/EscrowVault.ts +0 -255
  114. package/src/protocol/EventMonitor.ts +0 -204
  115. package/src/protocol/MessageSigner.ts +0 -510
  116. package/src/protocol/ProofGenerator.ts +0 -339
  117. package/src/protocol/QuoteBuilder.ts +0 -15
  118. package/src/registry/AgentRegistryClient.ts +0 -202
  119. package/src/runtime/BlockchainRuntime.ts +0 -1015
  120. package/src/runtime/IACTPRuntime.ts +0 -306
  121. package/src/runtime/MockRuntime.ts +0 -1298
  122. package/src/runtime/MockStateManager.ts +0 -577
  123. package/src/runtime/index.ts +0 -25
  124. package/src/runtime/types/MockState.ts +0 -237
  125. package/src/storage/ArchiveBundleBuilder.ts +0 -561
  126. package/src/storage/ArweaveClient.ts +0 -946
  127. package/src/storage/FilebaseClient.ts +0 -790
  128. package/src/storage/index.ts +0 -96
  129. package/src/storage/types.ts +0 -348
  130. package/src/types/adapter.ts +0 -310
  131. package/src/types/agent.ts +0 -79
  132. package/src/types/did.ts +0 -223
  133. package/src/types/eip712.ts +0 -175
  134. package/src/types/erc8004.ts +0 -293
  135. package/src/types/escrow.ts +0 -27
  136. package/src/types/index.ts +0 -17
  137. package/src/types/message.ts +0 -145
  138. package/src/types/state.ts +0 -87
  139. package/src/types/transaction.ts +0 -69
  140. package/src/types/x402.ts +0 -251
  141. package/src/utils/ErrorRecoveryGuide.ts +0 -676
  142. package/src/utils/Helpers.ts +0 -688
  143. package/src/utils/IPFSClient.ts +0 -368
  144. package/src/utils/Logger.ts +0 -484
  145. package/src/utils/NonceManager.ts +0 -591
  146. package/src/utils/RateLimiter.ts +0 -534
  147. package/src/utils/ReceivedNonceTracker.ts +0 -567
  148. package/src/utils/SDKLifecycle.ts +0 -416
  149. package/src/utils/SecureNonce.ts +0 -78
  150. package/src/utils/Semaphore.ts +0 -276
  151. package/src/utils/UsedAttestationTracker.ts +0 -385
  152. package/src/utils/canonicalJson.ts +0 -38
  153. package/src/utils/circuitBreaker.ts +0 -324
  154. package/src/utils/computeTypeHash.ts +0 -48
  155. package/src/utils/fsSafe.ts +0 -80
  156. package/src/utils/index.ts +0 -80
  157. package/src/utils/retry.ts +0 -364
  158. package/src/utils/security.ts +0 -418
  159. package/src/utils/validation.ts +0 -540
  160. package/src/wallet/AutoWalletProvider.ts +0 -299
  161. package/src/wallet/EOAWalletProvider.ts +0 -69
  162. package/src/wallet/IWalletProvider.ts +0 -135
  163. package/src/wallet/aa/BundlerClient.ts +0 -274
  164. package/src/wallet/aa/DualNonceManager.ts +0 -173
  165. package/src/wallet/aa/PaymasterClient.ts +0 -174
  166. package/src/wallet/aa/TransactionBatcher.ts +0 -353
  167. package/src/wallet/aa/UserOpBuilder.ts +0 -246
  168. package/src/wallet/aa/constants.ts +0 -60
  169. package/src/wallet/keystore.ts +0 -240
@@ -1,262 +0,0 @@
1
- /**
2
- * AGIRAILS.md Parser + Canonical Hash
3
- *
4
- * Parses AGIRAILS.md files (YAML frontmatter + markdown body),
5
- * computes deterministic canonical hashes for on-chain verification.
6
- *
7
- * ## Canonical Hash Algorithm
8
- *
9
- * 1. Parse YAML frontmatter into a plain object
10
- * 2. **Strip publish metadata keys** (config_hash, published_at, config_cid, arweave_tx)
11
- * — these are written back by the publish pipeline and must not affect the hash
12
- * 3. Canonicalize frontmatter:
13
- * - Object keys: sorted lexicographically (recursive)
14
- * - Primitive arrays: sorted lexicographically by `String(value).localeCompare()`
15
- * - Object arrays: order preserved (semantic ordering matters)
16
- * - Date objects: converted to ISO-8601 string (`.toISOString()`)
17
- * - null/undefined: preserved as-is
18
- * 4. `structuredHash = keccak256(JSON.stringify(canonical))`
19
- * 5. Normalize body: CRLF→LF, strip trailing whitespace per line, trim
20
- * 6. `bodyHash = keccak256(normalizedBody)`
21
- * 7. `configHash = keccak256(structuredHash ++ bodyHash)` (byte concatenation)
22
- *
23
- * @module config/agirailsmd
24
- */
25
-
26
- import { ethers } from 'ethers';
27
- import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
28
-
29
- // ============================================================================
30
- // Types
31
- // ============================================================================
32
-
33
- export interface AgirailsMdConfig {
34
- /** Parsed YAML frontmatter as a plain object */
35
- frontmatter: Record<string, unknown>;
36
- /** Markdown body (everything after the closing ---) */
37
- body: string;
38
- }
39
-
40
- export interface AgirailsMdHashResult {
41
- /** Final configHash = keccak256(structuredHash + bodyHash) */
42
- configHash: string;
43
- /** Hash of the canonical JSON representation of frontmatter */
44
- structuredHash: string;
45
- /** Hash of the normalized markdown body */
46
- bodyHash: string;
47
- }
48
-
49
- // ============================================================================
50
- // Publish Metadata (excluded from hash computation)
51
- // ============================================================================
52
-
53
- /**
54
- * Frontmatter keys written by the publish pipeline.
55
- * These are stripped before hash computation to prevent self-reference drift:
56
- * publish writes config_hash back → changes frontmatter → changes hash → never in sync.
57
- */
58
- export const PUBLISH_METADATA_KEYS = [
59
- 'config_hash',
60
- 'published_at',
61
- 'config_cid',
62
- 'arweave_tx',
63
- 'template_source',
64
- ] as const;
65
-
66
- /**
67
- * Strip publish metadata keys from a frontmatter object.
68
- * Returns a shallow copy with the metadata keys removed.
69
- */
70
- export function stripPublishMetadata(
71
- frontmatter: Record<string, unknown>
72
- ): Record<string, unknown> {
73
- const stripped = { ...frontmatter };
74
- for (const key of PUBLISH_METADATA_KEYS) {
75
- delete stripped[key];
76
- }
77
- return stripped;
78
- }
79
-
80
- // ============================================================================
81
- // Parser
82
- // ============================================================================
83
-
84
- /**
85
- * Parse an AGIRAILS.md file into frontmatter + body.
86
- *
87
- * @param content - Raw file content (string)
88
- * @returns Parsed config with frontmatter object and body string
89
- * @throws Error if content has no valid YAML frontmatter
90
- */
91
- export function parseAgirailsMd(content: string): AgirailsMdConfig {
92
- const trimmed = content.trimStart();
93
-
94
- if (!trimmed.startsWith('---')) {
95
- throw new Error('AGIRAILS.md must start with YAML frontmatter (---)');
96
- }
97
-
98
- // Find closing ---
99
- const closingIndex = trimmed.indexOf('\n---', 3);
100
- if (closingIndex === -1) {
101
- throw new Error('AGIRAILS.md frontmatter is not closed (missing closing ---)');
102
- }
103
-
104
- const yamlContent = trimmed.slice(4, closingIndex); // skip opening ---\n
105
- const body = trimmed.slice(closingIndex + 4); // skip \n---
106
-
107
- // Parse YAML
108
- let frontmatter: Record<string, unknown>;
109
- try {
110
- frontmatter = parseYaml(yamlContent);
111
- } catch (err) {
112
- const message = err instanceof Error ? err.message : String(err);
113
- throw new Error(`Failed to parse YAML frontmatter: ${message}`);
114
- }
115
-
116
- if (typeof frontmatter !== 'object' || frontmatter === null) {
117
- throw new Error('YAML frontmatter must be an object');
118
- }
119
-
120
- return {
121
- frontmatter,
122
- body: body.startsWith('\n') ? body.slice(1) : body,
123
- };
124
- }
125
-
126
- // ============================================================================
127
- // Canonical Hash
128
- // ============================================================================
129
-
130
- /**
131
- * Recursively canonicalize a value for deterministic JSON serialization.
132
- *
133
- * - Object keys: sorted lexicographically
134
- * - Primitive arrays: sorted by String(x).localeCompare()
135
- * - Object arrays: order preserved
136
- * - Date objects: converted to ISO-8601 string
137
- * - null/undefined: preserved
138
- */
139
- export function canonicalize(value: unknown): unknown {
140
- if (value === null || value === undefined) {
141
- return value;
142
- }
143
-
144
- // Handle Date objects deterministically (YAML parser may auto-create these)
145
- if (value instanceof Date) {
146
- return value.toISOString();
147
- }
148
-
149
- if (Array.isArray(value)) {
150
- // Canonicalize each element, then sort arrays of primitives lexicographically
151
- const canonicalized = value.map(canonicalize);
152
-
153
- // Only sort arrays of primitives (strings, numbers, booleans)
154
- // Arrays of objects maintain order (e.g., onboarding questions have semantic ordering)
155
- const allPrimitive = canonicalized.every(
156
- (item) => typeof item === 'string' || typeof item === 'number' || typeof item === 'boolean'
157
- );
158
-
159
- if (allPrimitive) {
160
- return canonicalized.sort((a, b) => String(a).localeCompare(String(b)));
161
- }
162
-
163
- return canonicalized;
164
- }
165
-
166
- if (typeof value === 'object') {
167
- const sorted: Record<string, unknown> = {};
168
- const keys = Object.keys(value as Record<string, unknown>).sort();
169
- for (const key of keys) {
170
- sorted[key] = canonicalize((value as Record<string, unknown>)[key]);
171
- }
172
- return sorted;
173
- }
174
-
175
- return value;
176
- }
177
-
178
- /**
179
- * Normalize markdown body for deterministic hashing.
180
- * - Strip trailing whitespace from each line
181
- * - Ensure \n line endings
182
- * - Trim leading/trailing whitespace
183
- */
184
- function normalizeBody(body: string): string {
185
- return body
186
- .replace(/\r\n/g, '\n') // CRLF → LF
187
- .replace(/\r/g, '\n') // CR → LF
188
- .split('\n')
189
- .map((line) => line.trimEnd()) // strip trailing whitespace per line
190
- .join('\n')
191
- .trim(); // trim leading/trailing
192
- }
193
-
194
- /**
195
- * Compute the canonical config hash from raw AGIRAILS.md content.
196
- *
197
- * @param content - Raw AGIRAILS.md file content
198
- * @returns Hash result with configHash, structuredHash, and bodyHash
199
- */
200
- export function computeConfigHash(content: string): AgirailsMdHashResult {
201
- const { frontmatter, body } = parseAgirailsMd(content);
202
- return computeConfigHashFromParts(frontmatter, body);
203
- }
204
-
205
- /**
206
- * Compute the canonical config hash from parsed parts.
207
- *
208
- * Publish metadata keys (config_hash, published_at, config_cid, arweave_tx)
209
- * are automatically stripped before hashing to prevent self-reference drift.
210
- *
211
- * @param frontmatter - Parsed YAML frontmatter object
212
- * @param body - Markdown body string
213
- * @returns Hash result with configHash, structuredHash, and bodyHash
214
- */
215
- export function computeConfigHashFromParts(
216
- frontmatter: Record<string, unknown>,
217
- body: string
218
- ): AgirailsMdHashResult {
219
- // Step 0: Strip publish metadata to prevent self-reference drift
220
- const stripped = stripPublishMetadata(frontmatter);
221
-
222
- // Step 1: Canonical JSON of frontmatter (with metadata stripped)
223
- const canonical = canonicalize(stripped);
224
- const canonicalJson = JSON.stringify(canonical);
225
- const structuredHash = ethers.keccak256(ethers.toUtf8Bytes(canonicalJson));
226
-
227
- // Step 2: Normalized body hash
228
- const normalized = normalizeBody(body);
229
- const bodyHash = ethers.keccak256(ethers.toUtf8Bytes(normalized));
230
-
231
- // Step 3: Combined hash
232
- const configHash = ethers.keccak256(
233
- ethers.concat([ethers.getBytes(structuredHash), ethers.getBytes(bodyHash)])
234
- );
235
-
236
- return { configHash, structuredHash, bodyHash };
237
- }
238
-
239
- // ============================================================================
240
- // Serializer
241
- // ============================================================================
242
-
243
- /**
244
- * Serialize config back to AGIRAILS.md format.
245
- *
246
- * @param frontmatter - YAML frontmatter object
247
- * @param body - Markdown body string
248
- * @returns Complete AGIRAILS.md file content
249
- */
250
- export function serializeAgirailsMd(
251
- frontmatter: Record<string, unknown>,
252
- body: string
253
- ): string {
254
- const yamlStr = stringifyYaml(frontmatter, {
255
- lineWidth: 120,
256
- singleQuote: false,
257
- }).trimEnd();
258
-
259
- const normalizedBody = body.startsWith('\n') ? body : `\n${body}`;
260
-
261
- return `---\n${yamlStr}\n---\n${normalizedBody}`;
262
- }
@@ -1,275 +0,0 @@
1
- import { ethers } from 'ethers';
2
-
3
- // ============================================================================
4
- // SECURITY FIX (C-7): RPC URL Configuration
5
- // ============================================================================
6
- // Environment variables take priority over hardcoded defaults.
7
- // This prevents accidental API key leakage if developers modify this file.
8
- // Public RPC endpoints are used as fallbacks for ease of use.
9
- //
10
- // Set these environment variables to use your own RPC provider:
11
- // BASE_SEPOLIA_RPC - Custom RPC for Base Sepolia testnet
12
- // BASE_MAINNET_RPC - Custom RPC for Base Mainnet
13
- // ============================================================================
14
-
15
- const BASE_SEPOLIA_RPC_URL = process.env.BASE_SEPOLIA_RPC || 'https://sepolia.base.org';
16
- const BASE_MAINNET_RPC_URL = process.env.BASE_MAINNET_RPC || 'https://mainnet.base.org';
17
-
18
- // AGIRAILS CDP Client API Key — safe to embed, cannot access funds/portfolios.
19
- // Developers can override with their own key via CDP_API_KEY env var.
20
- // Paymaster policy restricts sponsorship to AGIRAILS contracts only.
21
- const CDP_CLIENT_KEY = process.env.CDP_API_KEY || '2txciN85t41erCjveqgNnXYyHRcoo5xP';
22
-
23
- // Pimlico failover — bundler/paymaster backup if Coinbase CDP is down.
24
- // Safe to embed: restricted by contract allowlist (AGIRAILS contracts only).
25
- // Developers can override with their own key via PIMLICO_API_KEY env var.
26
- const PIMLICO_KEY = process.env.PIMLICO_API_KEY || 'pim_YiHmeAijzTPUvo1UMmXUiN';
27
-
28
- /**
29
- * Network configuration
30
- */
31
- export interface NetworkConfig {
32
- name: string;
33
- chainId: number;
34
- rpcUrl: string;
35
- blockExplorer: string;
36
- contracts: {
37
- actpKernel: string;
38
- escrowVault: string;
39
- usdc: string;
40
- eas: string; // EAS contract address
41
- easSchemaRegistry: string; // EAS SchemaRegistry contract
42
- agentRegistry?: string; // AIP-7 Agent Registry (optional until deployed)
43
- identityRegistry?: string; // AIP-7 ERC-1056 DID Registry (optional until deployed)
44
- archiveTreasury?: string; // AIP-7 Archive Treasury for Arweave funding (optional until deployed)
45
- x402Relay?: string; // X402Relay for atomic payment fee splitting (optional until deployed)
46
- };
47
- eas: {
48
- deliverySchemaUID: string; // AIP-4 delivery proof schema
49
- configSnapshotSchemaUID?: string; // AGIRAILS.md config snapshot schema
50
- };
51
- gasSettings: {
52
- maxFeePerGas: bigint;
53
- maxPriorityFeePerGas: bigint;
54
- };
55
- /**
56
- * Maximum transaction amount in USDC (human-readable, e.g., 100 = $100)
57
- *
58
- * SECURITY: Limits exposure on unaudited mainnet contracts.
59
- * Set to undefined for no limit (testnet only).
60
- */
61
- maxTransactionAmount?: number;
62
-
63
- /**
64
- * AIP-12: Account Abstraction (AA) configuration.
65
- * EntryPoint v0.6 + CoinbaseSmartWallet.
66
- */
67
- aa?: {
68
- /** ERC-4337 EntryPoint v0.6 address */
69
- entryPoint: string;
70
- /** CoinbaseSmartWallet factory address */
71
- smartWalletFactory: string;
72
- /** Bundler RPC URLs */
73
- bundlerUrls: {
74
- coinbase: string;
75
- pimlico?: string;
76
- };
77
- /** Paymaster RPC URLs (ERC-7677) */
78
- paymasterUrls: {
79
- coinbase: string;
80
- pimlico?: string;
81
- };
82
- };
83
- }
84
-
85
- /**
86
- * Base Sepolia Testnet Configuration
87
- */
88
- export const BASE_SEPOLIA: NetworkConfig = {
89
- name: 'Base Sepolia',
90
- chainId: 84532,
91
- rpcUrl: BASE_SEPOLIA_RPC_URL,
92
- blockExplorer: 'https://sepolia.basescan.org',
93
- contracts: {
94
- actpKernel: '0x469CBADbACFFE096270594F0a31f0EEC53753411',
95
- escrowVault: '0x57f888261b629bB380dfb983f5DA6c70Ff2D49E5',
96
- usdc: '0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb', // MockUSDC
97
- eas: '0x4200000000000000000000000000000000000021',
98
- easSchemaRegistry: '0x4200000000000000000000000000000000000020',
99
- agentRegistry: '0xDd6D66924B43419F484aE981F174b803487AF25A',
100
- identityRegistry: '0xF64F748C7802a68Cb936a9213881fE74e83FDA97',
101
- archiveTreasury: '0xeB75DE7cF5ce77ab15BB0fFa3a2A79e6aaa554B0',
102
- x402Relay: '0x4DCD02b276Dbeab57c265B72435e90507b6Ac81A',
103
- },
104
- eas: {
105
- deliverySchemaUID: '0x1b0ebdf0bd20c28ec9d5362571ce8715a55f46e81c3de2f9b0d8e1b95fb5ffce'
106
- },
107
- gasSettings: {
108
- maxFeePerGas: ethers.parseUnits('2', 'gwei'),
109
- maxPriorityFeePerGas: ethers.parseUnits('1', 'gwei')
110
- },
111
- // AIP-12: Account Abstraction
112
- aa: {
113
- entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
114
- smartWalletFactory: '0xBA5ED110eFDBa3D005bfC882d75358ACBbB85842',
115
- bundlerUrls: {
116
- // Coinbase CDP bundler — set CDP_API_KEY env var
117
- coinbase: process.env.CDP_BUNDLER_URL || `https://api.developer.coinbase.com/rpc/v1/base-sepolia/${CDP_CLIENT_KEY}`,
118
- // Pimlico backup bundler — set PIMLICO_API_KEY env var
119
- pimlico: process.env.PIMLICO_BUNDLER_URL || `https://api.pimlico.io/v2/84532/rpc?apikey=${PIMLICO_KEY}`,
120
- },
121
- paymasterUrls: {
122
- // Coinbase CDP paymaster — same endpoint as bundler
123
- coinbase: process.env.CDP_PAYMASTER_URL || `https://api.developer.coinbase.com/rpc/v1/base-sepolia/${CDP_CLIENT_KEY}`,
124
- // Pimlico failover paymaster
125
- pimlico: process.env.PIMLICO_PAYMASTER_URL || `https://api.pimlico.io/v2/84532/rpc?apikey=${PIMLICO_KEY}`,
126
- },
127
- },
128
- };
129
-
130
- /**
131
- * Base Mainnet Configuration
132
- */
133
- export const BASE_MAINNET: NetworkConfig = {
134
- name: 'Base Mainnet',
135
- chainId: 8453,
136
- rpcUrl: BASE_MAINNET_RPC_URL,
137
- blockExplorer: 'https://basescan.org',
138
- contracts: {
139
- actpKernel: '0x132B9eB321dBB57c828B083844287171BDC92d29',
140
- escrowVault: '0x6aAF45882c4b0dD34130ecC790bb5Ec6be7fFb99',
141
- usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
142
- eas: '0x4200000000000000000000000000000000000021',
143
- easSchemaRegistry: '0x4200000000000000000000000000000000000020',
144
- agentRegistry: '0x6fB222CF3DDdf37Bcb248EE7BBBA42Fb41901de8',
145
- archiveTreasury: '0x0516C411C0E8d75D17A768022819a0a4FB3cA2f2',
146
- x402Relay: '0x81DFb954A3D58FEc24Fc9c946aC2C71a911609F8',
147
- },
148
- eas: {
149
- deliverySchemaUID: '0x166501e7476e2fcf9214c4c5144533c2957d56fe59d639effc1719a0658d9c9a'
150
- },
151
- gasSettings: {
152
- maxFeePerGas: ethers.parseUnits('0.5', 'gwei'),
153
- maxPriorityFeePerGas: ethers.parseUnits('0.1', 'gwei')
154
- },
155
- /**
156
- * SECURITY: $1,000 max transaction limit until contracts are audited.
157
- * This limits exposure in case of undiscovered vulnerabilities.
158
- * Will be removed/increased after formal security audit.
159
- */
160
- maxTransactionAmount: 1000,
161
- // AIP-12: Account Abstraction
162
- aa: {
163
- entryPoint: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
164
- smartWalletFactory: '0xBA5ED110eFDBa3D005bfC882d75358ACBbB85842',
165
- bundlerUrls: {
166
- coinbase: process.env.CDP_BUNDLER_URL || `https://api.developer.coinbase.com/rpc/v1/base/${CDP_CLIENT_KEY}`,
167
- // Pimlico backup bundler — set PIMLICO_API_KEY env var
168
- pimlico: process.env.PIMLICO_BUNDLER_URL || `https://api.pimlico.io/v2/8453/rpc?apikey=${PIMLICO_KEY}`,
169
- },
170
- paymasterUrls: {
171
- coinbase: process.env.CDP_PAYMASTER_URL || `https://api.developer.coinbase.com/rpc/v1/base/${CDP_CLIENT_KEY}`,
172
- // Pimlico failover paymaster
173
- pimlico: process.env.PIMLICO_PAYMASTER_URL || `https://api.pimlico.io/v2/8453/rpc?apikey=${PIMLICO_KEY}`,
174
- },
175
- },
176
- };
177
-
178
- /**
179
- * All supported networks
180
- */
181
- export const NETWORKS: Record<string, NetworkConfig> = {
182
- 'base-sepolia': BASE_SEPOLIA,
183
- 'base-mainnet': BASE_MAINNET
184
- };
185
-
186
- /**
187
- * Get network configuration by name (returns deep clone to prevent mutation)
188
- */
189
- export function getNetwork(network: string): NetworkConfig {
190
- const config = NETWORKS[network];
191
- if (!config) {
192
- throw new Error(
193
- `Unknown network: ${network}. Supported networks: ${Object.keys(NETWORKS).join(', ')}`
194
- );
195
- }
196
-
197
- // Validate that contracts are deployed (not zero addresses)
198
- validateNetworkConfig(config);
199
-
200
- // Deep clone to prevent global mutation
201
- return {
202
- name: config.name,
203
- chainId: config.chainId,
204
- rpcUrl: config.rpcUrl,
205
- blockExplorer: config.blockExplorer,
206
- contracts: {
207
- actpKernel: config.contracts.actpKernel,
208
- escrowVault: config.contracts.escrowVault,
209
- usdc: config.contracts.usdc,
210
- eas: config.contracts.eas,
211
- easSchemaRegistry: config.contracts.easSchemaRegistry,
212
- agentRegistry: config.contracts.agentRegistry,
213
- identityRegistry: config.contracts.identityRegistry,
214
- archiveTreasury: config.contracts.archiveTreasury,
215
- x402Relay: config.contracts.x402Relay
216
- },
217
- eas: {
218
- deliverySchemaUID: config.eas.deliverySchemaUID,
219
- configSnapshotSchemaUID: config.eas.configSnapshotSchemaUID
220
- },
221
- gasSettings: {
222
- maxFeePerGas: config.gasSettings.maxFeePerGas,
223
- maxPriorityFeePerGas: config.gasSettings.maxPriorityFeePerGas
224
- },
225
- ...(config.aa ? {
226
- aa: {
227
- entryPoint: config.aa.entryPoint,
228
- smartWalletFactory: config.aa.smartWalletFactory,
229
- bundlerUrls: { ...config.aa.bundlerUrls },
230
- paymasterUrls: { ...config.aa.paymasterUrls },
231
- }
232
- } : {}),
233
- };
234
- }
235
-
236
- /**
237
- * Validate network name
238
- */
239
- export function isValidNetwork(network: string): boolean {
240
- return network in NETWORKS;
241
- }
242
-
243
- /**
244
- * Validate that contract addresses are deployed (not zero addresses)
245
- *
246
- * @throws Error if any contract address is zero (0x000...000)
247
- */
248
- export function validateNetworkConfig(config: NetworkConfig): void {
249
- const zeroAddress = '0x0000000000000000000000000000000000000000';
250
- const errors: string[] = [];
251
-
252
- if (config.contracts.actpKernel === zeroAddress) {
253
- errors.push('ACTPKernel address is zero - contracts not yet deployed to this network');
254
- }
255
-
256
- if (config.contracts.escrowVault === zeroAddress) {
257
- errors.push('EscrowVault address is zero - contracts not yet deployed to this network');
258
- }
259
-
260
- if (config.contracts.usdc === zeroAddress) {
261
- errors.push('USDC address is zero - token contract not configured for this network');
262
- }
263
-
264
- if (errors.length > 0) {
265
- throw new Error(
266
- `Network configuration error for ${config.name} (chainId: ${config.chainId}):\n\n` +
267
- errors.map(e => ` ✗ ${e}`).join('\n') +
268
- `\n\nContracts must be deployed before using the SDK. Please:\n` +
269
- ` 1. Deploy contracts to ${config.name}\n` +
270
- ` 2. Update src/config/networks.ts with deployed addresses\n` +
271
- ` 3. Rebuild the SDK: npm run build`
272
- );
273
- }
274
- }
275
-