@barzkit/sdk 0.1.0 → 0.1.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/CHANGELOG.md +72 -0
- package/README.md +2 -2
- package/dist/index.cjs +26 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.2] - 2026-03-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `explorerUrl` field in `ChainConfig` — block explorer base URL per chain
|
|
13
|
+
- `getExplorerUrl(hash)` method on `BarzAgent` — returns full explorer link for a transaction
|
|
14
|
+
- Console warning when using Base mainnet (real funds at risk)
|
|
15
|
+
- Chain-specific unit tests (`tests/unit/chains.test.ts`)
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Updated package description and keywords for better discoverability
|
|
20
|
+
- Refactored chain tests into dedicated test file
|
|
21
|
+
|
|
22
|
+
## [0.1.1] - 2026-03-01
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- `batchTransactions()` — atomic multi-call in a single UserOperation
|
|
27
|
+
|
|
28
|
+
## [0.1.0] - 2026-02-28
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
|
|
32
|
+
#### Core API
|
|
33
|
+
|
|
34
|
+
- `createBarzAgent()` — create an ERC-4337 smart account wallet on any supported chain
|
|
35
|
+
- `sendTransaction()` — send gasless transactions via Pimlico bundler + paymaster
|
|
36
|
+
- `getBalance()` — query ETH and ERC-20 token balances
|
|
37
|
+
- `waitForTransaction()` — wait for on-chain confirmation with structured `TransactionReceipt`
|
|
38
|
+
- `getExplorerUrl()` — block explorer URL for any transaction hash
|
|
39
|
+
|
|
40
|
+
#### Multi-chain
|
|
41
|
+
|
|
42
|
+
- Chain support: Sepolia, Base Sepolia, Base mainnet
|
|
43
|
+
- `CHAIN_CONFIGS` / `getChainConfig` — chain configuration registry
|
|
44
|
+
- `TOKENS` — pre-configured token addresses (USDC, WETH, DAI) per chain
|
|
45
|
+
- Custom `rpcUrl` option in `AgentConfig`
|
|
46
|
+
- Console warning when using Base mainnet (real funds at risk)
|
|
47
|
+
|
|
48
|
+
#### Permissions
|
|
49
|
+
|
|
50
|
+
- `AgentPermissions` — spending limits, contract whitelists, time windows
|
|
51
|
+
- `getPermissions()` / `updatePermissions()` — runtime permission management
|
|
52
|
+
- Client-side validation: per-tx limit, daily spend cap, allowed contracts, time window
|
|
53
|
+
|
|
54
|
+
#### Safety
|
|
55
|
+
|
|
56
|
+
- `freeze()` / `unfreeze()` — client-side kill switch (Phase 1)
|
|
57
|
+
- `isActive()` — check whether the agent wallet is frozen
|
|
58
|
+
|
|
59
|
+
#### DX
|
|
60
|
+
|
|
61
|
+
- Human-readable AA error mapping (AA21, AA25, AA31, AA33, AA40/41)
|
|
62
|
+
- Typed error hierarchy: `BarzKitError`, `ConfigError`, `PermissionError`, `FrozenError`, `TransactionError`, `BundlerError`
|
|
63
|
+
- Config validation with actionable error messages
|
|
64
|
+
- Account `index` for deterministic multi-wallet derivation from the same owner key
|
|
65
|
+
- `gasless` config option (default: `true`)
|
|
66
|
+
- `ERC20_ABI` — common ERC-20 function ABIs for contract reads
|
|
67
|
+
- `AgentEvent` type definitions for future event hooks
|
|
68
|
+
- Dual-package build: ESM (`.mjs`) + CJS (`.js`) + DTS (`.d.ts`)
|
|
69
|
+
|
|
70
|
+
[0.1.2]: https://github.com/barzkit/sdk/compare/v0.1.1...v0.1.2
|
|
71
|
+
[0.1.1]: https://github.com/barzkit/sdk/compare/v0.1.0...v0.1.1
|
|
72
|
+
[0.1.0]: https://github.com/barzkit/sdk/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -142,7 +142,7 @@ Your AI Agent
|
|
|
142
142
|
|
|
143
143
|
## Examples
|
|
144
144
|
|
|
145
|
-
See [
|
|
145
|
+
See [examples](https://github.com/barzkit/examples) for complete working examples.
|
|
146
146
|
|
|
147
147
|
## Security
|
|
148
148
|
|
|
@@ -155,9 +155,9 @@ See [barzkit-examples](https://github.com/barzkit/examples) for complete working
|
|
|
155
155
|
## Roadmap
|
|
156
156
|
|
|
157
157
|
- [x] Core SDK: createWallet, sendTransaction, permissions, freeze
|
|
158
|
+
- [x] Batch transactions: atomic multi-call in one UserOperation
|
|
158
159
|
- [ ] Multi-chain: Base Sepolia, Base mainnet
|
|
159
160
|
- [ ] DeFi actions: swap, lend (Uniswap, Aave)
|
|
160
|
-
- [ ] Dashboard: Next.js agent management UI
|
|
161
161
|
- [ ] ElizaOS plugin
|
|
162
162
|
- [ ] LangChain tool
|
|
163
163
|
- [ ] x402 payment handler
|
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,8 @@ var CHAIN_CONFIGS = {
|
|
|
16
16
|
bundlerUrl: "https://api.pimlico.io/v2/sepolia/rpc",
|
|
17
17
|
paymasterUrl: "https://api.pimlico.io/v2/sepolia/rpc",
|
|
18
18
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
19
|
-
entryPointVersion: "0.6"
|
|
19
|
+
entryPointVersion: "0.6",
|
|
20
|
+
explorerUrl: "https://sepolia.etherscan.io"
|
|
20
21
|
},
|
|
21
22
|
"base-sepolia": {
|
|
22
23
|
chain: chains.baseSepolia,
|
|
@@ -24,7 +25,8 @@ var CHAIN_CONFIGS = {
|
|
|
24
25
|
bundlerUrl: "https://api.pimlico.io/v2/base-sepolia/rpc",
|
|
25
26
|
paymasterUrl: "https://api.pimlico.io/v2/base-sepolia/rpc",
|
|
26
27
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
27
|
-
entryPointVersion: "0.6"
|
|
28
|
+
entryPointVersion: "0.6",
|
|
29
|
+
explorerUrl: "https://sepolia.basescan.org"
|
|
28
30
|
},
|
|
29
31
|
base: {
|
|
30
32
|
chain: chains.base,
|
|
@@ -32,7 +34,8 @@ var CHAIN_CONFIGS = {
|
|
|
32
34
|
bundlerUrl: "https://api.pimlico.io/v2/base/rpc",
|
|
33
35
|
paymasterUrl: "https://api.pimlico.io/v2/base/rpc",
|
|
34
36
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
35
|
-
entryPointVersion: "0.6"
|
|
37
|
+
entryPointVersion: "0.6",
|
|
38
|
+
explorerUrl: "https://basescan.org"
|
|
36
39
|
}
|
|
37
40
|
};
|
|
38
41
|
function getChainConfig(chain) {
|
|
@@ -346,6 +349,9 @@ async function createBarzAgent(config) {
|
|
|
346
349
|
}
|
|
347
350
|
}
|
|
348
351
|
});
|
|
352
|
+
if (config.chain === "base") {
|
|
353
|
+
console.warn("\u26A0\uFE0F Using Base mainnet \u2014 real funds at risk");
|
|
354
|
+
}
|
|
349
355
|
const permissionManager = new PermissionManager(config.permissions);
|
|
350
356
|
let frozen = false;
|
|
351
357
|
const agent = {
|
|
@@ -370,20 +376,28 @@ async function createBarzAgent(config) {
|
|
|
370
376
|
async batchTransactions(txs) {
|
|
371
377
|
if (frozen) throw new FrozenError();
|
|
372
378
|
if (txs.length === 0) {
|
|
373
|
-
throw new
|
|
379
|
+
throw new BarzKitError(
|
|
380
|
+
"batchTransactions requires at least one transaction.",
|
|
381
|
+
"BATCH_EMPTY"
|
|
382
|
+
);
|
|
374
383
|
}
|
|
375
384
|
for (const tx of txs) {
|
|
376
385
|
permissionManager.validate(tx);
|
|
377
386
|
}
|
|
378
387
|
try {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
388
|
+
const userOpHash = await smartAccountClient.sendUserOperation({
|
|
389
|
+
calls: txs.map((tx) => ({
|
|
390
|
+
to: tx.to,
|
|
391
|
+
value: tx.value ?? 0n,
|
|
392
|
+
data: tx.data ?? "0x"
|
|
393
|
+
}))
|
|
394
|
+
});
|
|
395
|
+
const receipt = await smartAccountClient.waitForUserOperationReceipt({
|
|
396
|
+
hash: userOpHash
|
|
383
397
|
});
|
|
384
398
|
const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n);
|
|
385
399
|
if (totalValue > 0n) permissionManager.recordSpend(totalValue);
|
|
386
|
-
return
|
|
400
|
+
return receipt.receipt.transactionHash;
|
|
387
401
|
} catch (error) {
|
|
388
402
|
throw humanizeError(error);
|
|
389
403
|
}
|
|
@@ -420,6 +434,9 @@ async function createBarzAgent(config) {
|
|
|
420
434
|
);
|
|
421
435
|
}
|
|
422
436
|
},
|
|
437
|
+
getExplorerUrl(hash) {
|
|
438
|
+
return `${chainConfig.explorerUrl}/tx/${hash}`;
|
|
439
|
+
},
|
|
423
440
|
getPermissions() {
|
|
424
441
|
return permissionManager.permissions;
|
|
425
442
|
},
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chains/chains.ts","../src/utils/errors.ts","../src/core/client.ts","../src/permissions/permissions.ts","../src/utils/constants.ts","../src/core/account.ts"],"names":["sepolia","baseSepolia","base","createPublicClient","http","createPimlicoClient","entryPoint06Address","privateKeyToAccount","toTrustSmartAccount","createSmartAccountClient"],"mappings":";;;;;;;;;;;AAGO,IAAM,aAAA,GAAqD;AAAA,EAChE,OAAA,EAAS;AAAA,IACP,KAAA,EAAOA,cAAA;AAAA,IACP,MAAA,EAAQ,6CAAA;AAAA,IACR,UAAA,EAAY,uCAAA;AAAA,IACZ,YAAA,EAAc,uCAAA;AAAA,IACd,iBAAA,EAAmB,4C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AA,EAAO;AACjB,IAAA,MAAM,IAAI,YAAY,6CAA6C,CAAA;AAAA,EACrE;AACA,EAAA,IAAI,CAAC,OAAO,KAAA,CAAM,UAAA,CAAW,IAAI,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,MAAA,KAAW,EAAA,EAAI;AAChE,IAAA,MAAM,IAAI,WAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,OAAA,EAAS,MAAA,EAAQ;AAC3B,IAAA,MAAM,IAAI,YAAY,0EAA0E,CAAA;AAAA,EAClG;AACF","file":"index.cjs","sourcesContent":["import { sepolia, baseSepolia, base } from 'viem/chains'\nimport type { ChainConfig, SupportedChain } from '../core/types'\n\nexport const CHAIN_CONFIGS: Record<SupportedChain, ChainConfig> = {\n sepolia: {\n chain: sepolia,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n bundlerUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n },\n 'base-sepolia': {\n chain: baseSepolia,\n rpcUrl: 'https://sepolia.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n },\n base: {\n chain: base,\n rpcUrl: 'https://mainnet.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n },\n}\n\nexport function getChainConfig(chain: SupportedChain): ChainConfig {\n const config = CHAIN_CONFIGS[chain]\n if (!config) {\n const supported = Object.keys(CHAIN_CONFIGS).join(', ')\n throw new Error(`Unsupported chain: \"${chain}\". Supported: ${supported}`)\n }\n return config\n}\n\nexport function buildBundlerUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.bundlerUrl}?apikey=${apiKey}`\n}\n\nexport function buildPaymasterUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.paymasterUrl}?apikey=${apiKey}`\n}\n","export class BarzKitError extends Error {\n public readonly code: string\n\n constructor(message: string, code: string) {\n super(message)\n this.name = 'BarzKitError'\n this.code = code\n }\n}\n\nexport class ConfigError extends BarzKitError {\n constructor(message: string) {\n super(message, 'CONFIG_ERROR')\n this.name = 'ConfigError'\n }\n}\n\nexport class PermissionError extends BarzKitError {\n constructor(message: string) {\n super(message, 'PERMISSION_DENIED')\n this.name = 'PermissionError'\n }\n}\n\nexport class FrozenError extends BarzKitError {\n constructor() {\n super(\n 'Agent wallet is frozen. Call agent.unfreeze() to resume operation.',\n 'AGENT_FROZEN',\n )\n this.name = 'FrozenError'\n }\n}\n\nexport class TransactionError extends BarzKitError {\n public readonly txHash?: string\n\n constructor(message: string, txHash?: string) {\n super(message, 'TRANSACTION_FAILED')\n this.name = 'TransactionError'\n this.txHash = txHash\n }\n}\n\nexport class BundlerError extends BarzKitError {\n constructor(message: string) {\n super(message, 'BUNDLER_ERROR')\n this.name = 'BundlerError'\n }\n}\n\nexport function humanizeError(error: unknown): BarzKitError {\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('AA21')) {\n return new TransactionError(\n 'Smart account has insufficient funds to pay for gas. ' +\n 'Send ETH to the agent wallet address, or enable gasless mode.',\n )\n }\n\n if (message.includes('AA25')) {\n return new TransactionError(\n 'Invalid signature. The agent key may not be authorized for this account.',\n )\n }\n\n if (message.includes('AA31')) {\n return new TransactionError(\n 'Paymaster deposit too low. The paymaster may be out of funds. ' +\n 'Try again later or switch to self-funded mode.',\n )\n }\n\n if (message.includes('AA33')) {\n return new TransactionError(\n 'Transaction reverted during validation. The calldata may be invalid ' +\n 'or the target contract may have rejected the call.',\n )\n }\n\n if (message.includes('AA40') || message.includes('AA41')) {\n return new TransactionError(\n 'Paymaster validation failed. The paymaster may not support this operation.',\n )\n }\n\n if (message.includes('insufficient funds')) {\n return new TransactionError(\n 'Insufficient funds in the agent wallet. Check balance with agent.getBalance().',\n )\n }\n\n return new BarzKitError(`Transaction failed: ${message}`, 'UNKNOWN_ERROR')\n}\n","import { createPublicClient, http } from 'viem'\nimport type { PublicClient, HttpTransport, Chain } from 'viem'\nimport { createPimlicoClient } from 'permissionless/clients/pimlico'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport type { AgentConfig, ChainConfig } from './types'\nimport { getChainConfig, buildBundlerUrl } from '../chains/chains'\nimport { ConfigError } from '../utils/errors'\n\nexport interface BarzClients {\n publicClient: PublicClient<HttpTransport, Chain>\n pimlicoClient: ReturnType<typeof createPimlicoClient>\n chainConfig: ChainConfig\n bundlerUrl: string\n}\n\nexport function createClients(config: AgentConfig): BarzClients {\n if (!config.chain) {\n throw new ConfigError('Missing required field: \"chain\". Example: { chain: \"sepolia\" }')\n }\n if (!config.owner) {\n throw new ConfigError('Missing required field: \"owner\". Provide a hex private key.')\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError(\n 'Missing required field: \"pimlico.apiKey\". ' +\n 'Get a free API key at https://dashboard.pimlico.io',\n )\n }\n\n const chainConfig = getChainConfig(config.chain)\n const rpcUrl = config.rpcUrl || chainConfig.rpcUrl\n const bundlerUrl = buildBundlerUrl(chainConfig, config.pimlico.apiKey)\n\n const publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n })\n\n const pimlicoClient = createPimlicoClient({\n transport: http(bundlerUrl),\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n return {\n publicClient: publicClient as PublicClient<HttpTransport, Chain>,\n pimlicoClient,\n chainConfig,\n bundlerUrl,\n }\n}\n","import type { AgentPermissions, TransactionRequest } from '../core/types'\nimport { PermissionError } from '../utils/errors'\n\nexport class PermissionManager {\n private _permissions: AgentPermissions\n private _dailySpent: bigint = 0n\n private _dailyResetTime: number = Date.now()\n\n constructor(permissions: AgentPermissions = {}) {\n this._permissions = { ...permissions }\n }\n\n get permissions(): AgentPermissions {\n return { ...this._permissions }\n }\n\n update(permissions: Partial<AgentPermissions>): void {\n this._permissions = { ...this._permissions, ...permissions }\n }\n\n validate(tx: TransactionRequest): void {\n const p = this._permissions\n\n // Check allowed contracts\n if (p.allowedContracts && p.allowedContracts.length > 0) {\n const target = tx.to.toLowerCase()\n const allowed = p.allowedContracts.map((a) => a.toLowerCase())\n if (!allowed.includes(target)) {\n throw new PermissionError(\n `Target contract ${tx.to} is not in the allowed list. ` +\n `Allowed: ${p.allowedContracts.join(', ')}`,\n )\n }\n }\n\n // Check time window\n if (p.timeWindow) {\n const now = new Date()\n const hours = now.getUTCHours()\n const minutes = now.getUTCMinutes()\n const currentTime = hours * 60 + minutes\n\n const [startH, startM] = p.timeWindow.start.split(':').map(Number)\n const [endH, endM] = p.timeWindow.end.split(':').map(Number)\n const startTime = startH * 60 + startM\n const endTime = endH * 60 + endM\n\n if (currentTime < startTime || currentTime > endTime) {\n throw new PermissionError(\n `Transaction outside allowed time window. ` +\n `Allowed: ${p.timeWindow.start} - ${p.timeWindow.end} UTC. ` +\n `Current: ${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')} UTC.`,\n )\n }\n }\n\n // Check per-transaction amount limit\n if (p.maxAmountPerTx && tx.value) {\n const limit = parseHumanAmount(p.maxAmountPerTx)\n if (limit !== null && tx.value > limit) {\n throw new PermissionError(\n `Transaction value ${tx.value} exceeds per-transaction limit of ${p.maxAmountPerTx}.`,\n )\n }\n }\n\n // Check daily spend\n if (p.maxDailySpend && tx.value) {\n this._resetDailyIfNeeded()\n const limit = parseHumanAmount(p.maxDailySpend)\n if (limit !== null && this._dailySpent + tx.value > limit) {\n throw new PermissionError(\n `Transaction would exceed daily spend limit of ${p.maxDailySpend}. ` +\n `Already spent today: ${this._dailySpent}. Requested: ${tx.value}.`,\n )\n }\n }\n }\n\n recordSpend(value: bigint): void {\n this._resetDailyIfNeeded()\n this._dailySpent += value\n }\n\n private _resetDailyIfNeeded(): void {\n const now = Date.now()\n const ONE_DAY = 24 * 60 * 60 * 1000\n if (now - this._dailyResetTime > ONE_DAY) {\n this._dailySpent = 0n\n this._dailyResetTime = now\n }\n }\n}\n\nfunction parseHumanAmount(amount: string): bigint | null {\n const parts = amount.trim().split(/\\s+/)\n const num = parseFloat(parts[0])\n if (isNaN(num)) return null\n\n const unit = parts[1]?.toUpperCase() || 'WEI'\n\n switch (unit) {\n case 'ETH':\n return BigInt(Math.floor(num * 1e18))\n case 'GWEI':\n return BigInt(Math.floor(num * 1e9))\n case 'WEI':\n return BigInt(Math.floor(num))\n case 'USDC':\n case 'USDT':\n return BigInt(Math.floor(num * 1e6))\n case 'DAI':\n return BigInt(Math.floor(num * 1e18))\n default:\n return null\n }\n}\n","import type { Address } from 'viem'\n\nexport const TOKENS: Record<string, Record<string, Address>> = {\n sepolia: {\n USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n WETH: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',\n DAI: '0x68194a729C2450ad26072b3D33ADaCbcef39D574',\n },\n 'base-sepolia': {\n USDC: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n WETH: '0x4200000000000000000000000000000000000006',\n },\n base: {\n USDC: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n WETH: '0x4200000000000000000000000000000000000006',\n DAI: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',\n USDbC: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',\n },\n}\n\nexport const ERC20_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'approve',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [],\n name: 'decimals',\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [],\n name: 'symbol',\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n","import { http } from 'viem'\nimport type { Address, Hash, Hex } from 'viem'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport { createSmartAccountClient } from 'permissionless'\nimport { toTrustSmartAccount } from 'permissionless/accounts'\n\nimport type {\n AgentConfig,\n BarzAgent,\n TransactionRequest,\n TransactionReceipt,\n AgentPermissions,\n} from './types'\nimport { createClients } from './client'\nimport { PermissionManager } from '../permissions/permissions'\nimport { ConfigError, FrozenError, humanizeError, TransactionError } from '../utils/errors'\nimport { ERC20_ABI } from '../utils/constants'\n\n/**\n * Create a Barz agent wallet.\n *\n * @example\n * ```ts\n * const agent = await createBarzAgent({\n * chain: 'sepolia',\n * owner: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n * pimlico: { apiKey: 'pim_...' },\n * })\n *\n * console.log('Agent address:', agent.address)\n * ```\n */\nexport async function createBarzAgent(config: AgentConfig): Promise<BarzAgent> {\n validateConfig(config)\n\n const { publicClient, pimlicoClient, chainConfig, bundlerUrl } = createClients(config)\n const ownerAccount = privateKeyToAccount(config.owner)\n\n const smartAccount = await toTrustSmartAccount({\n client: publicClient,\n owner: ownerAccount,\n index: config.index ?? 0n,\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n const gasless = config.gasless !== false\n\n const smartAccountClient = createSmartAccountClient({\n account: smartAccount,\n chain: chainConfig.chain,\n bundlerTransport: http(bundlerUrl),\n ...(gasless\n ? {\n paymaster: pimlicoClient,\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }\n : {\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }),\n })\n\n const permissionManager = new PermissionManager(config.permissions)\n let frozen = false\n\n const agent: BarzAgent = {\n address: smartAccount.address,\n chain: config.chain,\n owner: ownerAccount.address,\n\n async sendTransaction(tx: TransactionRequest): Promise<Hash> {\n if (frozen) throw new FrozenError()\n permissionManager.validate(tx)\n\n try {\n const hash = await smartAccountClient.sendTransaction({\n to: tx.to,\n value: tx.value ?? 0n,\n data: tx.data ?? '0x',\n })\n\n if (tx.value) permissionManager.recordSpend(tx.value)\n return hash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async batchTransactions(txs: TransactionRequest[]): Promise<Hash> {\n if (frozen) throw new FrozenError()\n if (txs.length === 0) {\n throw new ConfigError('batchTransactions requires at least one transaction.')\n }\n\n for (const tx of txs) {\n permissionManager.validate(tx)\n }\n\n try {\n // TODO: actual batch encoding when permissionless.js supports it\n const hash = await smartAccountClient.sendTransaction({\n to: txs[0].to,\n value: txs[0].value ?? 0n,\n data: txs[0].data ?? ('0x' as Hex),\n })\n\n const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n)\n if (totalValue > 0n) permissionManager.recordSpend(totalValue)\n\n return hash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async getBalance(token?: Address): Promise<bigint> {\n try {\n if (!token) {\n return await publicClient.getBalance({ address: smartAccount.address })\n }\n\n const balance = await publicClient.readContract({\n address: token,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [smartAccount.address],\n })\n\n return balance as bigint\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async waitForTransaction(hash: Hash): Promise<TransactionReceipt> {\n try {\n const receipt = await publicClient.waitForTransactionReceipt({ hash })\n return {\n transactionHash: receipt.transactionHash,\n blockNumber: receipt.blockNumber,\n status: receipt.status,\n gasUsed: receipt.gasUsed,\n }\n } catch (error) {\n throw new TransactionError(\n `Failed waiting for transaction ${hash}: ${error instanceof Error ? error.message : error}`,\n hash,\n )\n }\n },\n\n getPermissions(): AgentPermissions {\n return permissionManager.permissions\n },\n\n updatePermissions(permissions: Partial<AgentPermissions>): void {\n permissionManager.update(permissions)\n },\n\n async freeze(): Promise<Hash> {\n frozen = true\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async unfreeze(): Promise<Hash> {\n frozen = false\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async isActive(): Promise<boolean> {\n return !frozen\n },\n }\n\n return agent\n}\n\nfunction validateConfig(config: AgentConfig): void {\n if (!config) throw new ConfigError('Agent config is required.')\n\n if (!config.chain) {\n throw new ConfigError('Missing \"chain\". Supported: sepolia, base-sepolia, base.')\n }\n if (!config.owner) {\n throw new ConfigError('Missing \"owner\". Provide a hex private key.')\n }\n if (!config.owner.startsWith('0x') || config.owner.length !== 66) {\n throw new ConfigError(\n 'Invalid \"owner\" private key. Must be a 32-byte hex string starting with \"0x\" (66 chars total).',\n )\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError('Missing \"pimlico.apiKey\". Get a free key at https://dashboard.pimlico.io')\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/chains/chains.ts","../src/utils/errors.ts","../src/core/client.ts","../src/permissions/permissions.ts","../src/utils/constants.ts","../src/core/account.ts"],"names":["sepolia","baseSepolia","base","createPublicClient","http","createPimlicoClient","entryPoint06Address","privateKeyToAccount","toTrustSmartAccount","createSmartAccountClient"],"mappings":";;;;;;;;;;;AAGO,IAAM,aAAA,GAAqD;AAAA,EAChE,OAAA,EAAS;AAAA,IACP,KAAA,EAAOA,cAAA;AAAA,IACP,M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,iBAAA,CAAkB,OAAO,WAAW,CAAA;AAAA,IACtC,CAAA;AAAA,IAEA,MAAM,MAAA,GAAwB;AAC5B,MAAA,MAAA,GAAS,IAAA;AACT,MAAA,OAAO,oEAAA;AAAA,IACT,CAAA;AAAA,IAEA,MAAM,QAAA,GAA0B;AAC9B,MAAA,MAAA,GAAS,KAAA;AACT,MAAA,OAAO,oEAAA;AAAA,IACT,CAAA;AAAA,IAEA,MAAM,QAAA,GAA6B;AACjC,MAAA,OAAO,CAAC,MAAA;AAAA,IACV;AAAA,GACF;AAEA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,eAAe,MAAA,EAA2B;AACjD,EAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,YAAY,2BAA2B,CAAA;AAE9D,EAAA,IAAI,CAAC,OAAO,KAAA,EAAO;AACjB,IAAA,MAAM,IAAI,YAAY,0DAA0D,CAAA;AAAA,EAClF;AACA,EAAA,IAAI,CAAC,OAAO,KAAA,EAAO;AACjB,IAAA,MAAM,IAAI,YAAY,6CAA6C,CAAA;AAAA,EACrE;AACA,EAAA,IAAI,CAAC,OAAO,KAAA,CAAM,UAAA,CAAW,IAAI,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,MAAA,KAAW,EAAA,EAAI;AAChE,IAAA,MAAM,IAAI,WAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,OAAA,EAAS,MAAA,EAAQ;AAC3B,IAAA,MAAM,IAAI,YAAY,0EAA0E,CAAA;AAAA,EAClG;AACF","file":"index.cjs","sourcesContent":["import { sepolia, baseSepolia, base } from 'viem/chains'\nimport type { ChainConfig, SupportedChain } from '../core/types'\n\nexport const CHAIN_CONFIGS: Record<SupportedChain, ChainConfig> = {\n sepolia: {\n chain: sepolia,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n bundlerUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n explorerUrl: 'https://sepolia.etherscan.io',\n },\n 'base-sepolia': {\n chain: baseSepolia,\n rpcUrl: 'https://sepolia.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n explorerUrl: 'https://sepolia.basescan.org',\n },\n base: {\n chain: base,\n rpcUrl: 'https://mainnet.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n explorerUrl: 'https://basescan.org',\n },\n}\n\nexport function getChainConfig(chain: SupportedChain): ChainConfig {\n const config = CHAIN_CONFIGS[chain]\n if (!config) {\n const supported = Object.keys(CHAIN_CONFIGS).join(', ')\n throw new Error(`Unsupported chain: \"${chain}\". Supported: ${supported}`)\n }\n return config\n}\n\nexport function buildBundlerUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.bundlerUrl}?apikey=${apiKey}`\n}\n\nexport function buildPaymasterUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.paymasterUrl}?apikey=${apiKey}`\n}\n","export class BarzKitError extends Error {\n public readonly code: string\n\n constructor(message: string, code: string) {\n super(message)\n this.name = 'BarzKitError'\n this.code = code\n }\n}\n\nexport class ConfigError extends BarzKitError {\n constructor(message: string) {\n super(message, 'CONFIG_ERROR')\n this.name = 'ConfigError'\n }\n}\n\nexport class PermissionError extends BarzKitError {\n constructor(message: string) {\n super(message, 'PERMISSION_DENIED')\n this.name = 'PermissionError'\n }\n}\n\nexport class FrozenError extends BarzKitError {\n constructor() {\n super(\n 'Agent wallet is frozen. Call agent.unfreeze() to resume operation.',\n 'AGENT_FROZEN',\n )\n this.name = 'FrozenError'\n }\n}\n\nexport class TransactionError extends BarzKitError {\n public readonly txHash?: string\n\n constructor(message: string, txHash?: string) {\n super(message, 'TRANSACTION_FAILED')\n this.name = 'TransactionError'\n this.txHash = txHash\n }\n}\n\nexport class BundlerError extends BarzKitError {\n constructor(message: string) {\n super(message, 'BUNDLER_ERROR')\n this.name = 'BundlerError'\n }\n}\n\nexport function humanizeError(error: unknown): BarzKitError {\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('AA21')) {\n return new TransactionError(\n 'Smart account has insufficient funds to pay for gas. ' +\n 'Send ETH to the agent wallet address, or enable gasless mode.',\n )\n }\n\n if (message.includes('AA25')) {\n return new TransactionError(\n 'Invalid signature. The agent key may not be authorized for this account.',\n )\n }\n\n if (message.includes('AA31')) {\n return new TransactionError(\n 'Paymaster deposit too low. The paymaster may be out of funds. ' +\n 'Try again later or switch to self-funded mode.',\n )\n }\n\n if (message.includes('AA33')) {\n return new TransactionError(\n 'Transaction reverted during validation. The calldata may be invalid ' +\n 'or the target contract may have rejected the call.',\n )\n }\n\n if (message.includes('AA40') || message.includes('AA41')) {\n return new TransactionError(\n 'Paymaster validation failed. The paymaster may not support this operation.',\n )\n }\n\n if (message.includes('insufficient funds')) {\n return new TransactionError(\n 'Insufficient funds in the agent wallet. Check balance with agent.getBalance().',\n )\n }\n\n return new BarzKitError(`Transaction failed: ${message}`, 'UNKNOWN_ERROR')\n}\n","import { createPublicClient, http } from 'viem'\nimport type { PublicClient, HttpTransport, Chain } from 'viem'\nimport { createPimlicoClient } from 'permissionless/clients/pimlico'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport type { AgentConfig, ChainConfig } from './types'\nimport { getChainConfig, buildBundlerUrl } from '../chains/chains'\nimport { ConfigError } from '../utils/errors'\n\nexport interface BarzClients {\n publicClient: PublicClient<HttpTransport, Chain>\n pimlicoClient: ReturnType<typeof createPimlicoClient>\n chainConfig: ChainConfig\n bundlerUrl: string\n}\n\nexport function createClients(config: AgentConfig): BarzClients {\n if (!config.chain) {\n throw new ConfigError('Missing required field: \"chain\". Example: { chain: \"sepolia\" }')\n }\n if (!config.owner) {\n throw new ConfigError('Missing required field: \"owner\". Provide a hex private key.')\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError(\n 'Missing required field: \"pimlico.apiKey\". ' +\n 'Get a free API key at https://dashboard.pimlico.io',\n )\n }\n\n const chainConfig = getChainConfig(config.chain)\n const rpcUrl = config.rpcUrl || chainConfig.rpcUrl\n const bundlerUrl = buildBundlerUrl(chainConfig, config.pimlico.apiKey)\n\n const publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n })\n\n const pimlicoClient = createPimlicoClient({\n transport: http(bundlerUrl),\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n return {\n publicClient: publicClient as PublicClient<HttpTransport, Chain>,\n pimlicoClient,\n chainConfig,\n bundlerUrl,\n }\n}\n","import type { AgentPermissions, TransactionRequest } from '../core/types'\nimport { PermissionError } from '../utils/errors'\n\nexport class PermissionManager {\n private _permissions: AgentPermissions\n private _dailySpent: bigint = 0n\n private _dailyResetTime: number = Date.now()\n\n constructor(permissions: AgentPermissions = {}) {\n this._permissions = { ...permissions }\n }\n\n get permissions(): AgentPermissions {\n return { ...this._permissions }\n }\n\n update(permissions: Partial<AgentPermissions>): void {\n this._permissions = { ...this._permissions, ...permissions }\n }\n\n validate(tx: TransactionRequest): void {\n const p = this._permissions\n\n // Check allowed contracts\n if (p.allowedContracts && p.allowedContracts.length > 0) {\n const target = tx.to.toLowerCase()\n const allowed = p.allowedContracts.map((a) => a.toLowerCase())\n if (!allowed.includes(target)) {\n throw new PermissionError(\n `Target contract ${tx.to} is not in the allowed list. ` +\n `Allowed: ${p.allowedContracts.join(', ')}`,\n )\n }\n }\n\n // Check time window\n if (p.timeWindow) {\n const now = new Date()\n const hours = now.getUTCHours()\n const minutes = now.getUTCMinutes()\n const currentTime = hours * 60 + minutes\n\n const [startH, startM] = p.timeWindow.start.split(':').map(Number)\n const [endH, endM] = p.timeWindow.end.split(':').map(Number)\n const startTime = startH * 60 + startM\n const endTime = endH * 60 + endM\n\n if (currentTime < startTime || currentTime > endTime) {\n throw new PermissionError(\n `Transaction outside allowed time window. ` +\n `Allowed: ${p.timeWindow.start} - ${p.timeWindow.end} UTC. ` +\n `Current: ${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')} UTC.`,\n )\n }\n }\n\n // Check per-transaction amount limit\n if (p.maxAmountPerTx && tx.value) {\n const limit = parseHumanAmount(p.maxAmountPerTx)\n if (limit !== null && tx.value > limit) {\n throw new PermissionError(\n `Transaction value ${tx.value} exceeds per-transaction limit of ${p.maxAmountPerTx}.`,\n )\n }\n }\n\n // Check daily spend\n if (p.maxDailySpend && tx.value) {\n this._resetDailyIfNeeded()\n const limit = parseHumanAmount(p.maxDailySpend)\n if (limit !== null && this._dailySpent + tx.value > limit) {\n throw new PermissionError(\n `Transaction would exceed daily spend limit of ${p.maxDailySpend}. ` +\n `Already spent today: ${this._dailySpent}. Requested: ${tx.value}.`,\n )\n }\n }\n }\n\n recordSpend(value: bigint): void {\n this._resetDailyIfNeeded()\n this._dailySpent += value\n }\n\n private _resetDailyIfNeeded(): void {\n const now = Date.now()\n const ONE_DAY = 24 * 60 * 60 * 1000\n if (now - this._dailyResetTime > ONE_DAY) {\n this._dailySpent = 0n\n this._dailyResetTime = now\n }\n }\n}\n\nfunction parseHumanAmount(amount: string): bigint | null {\n const parts = amount.trim().split(/\\s+/)\n const num = parseFloat(parts[0])\n if (isNaN(num)) return null\n\n const unit = parts[1]?.toUpperCase() || 'WEI'\n\n switch (unit) {\n case 'ETH':\n return BigInt(Math.floor(num * 1e18))\n case 'GWEI':\n return BigInt(Math.floor(num * 1e9))\n case 'WEI':\n return BigInt(Math.floor(num))\n case 'USDC':\n case 'USDT':\n return BigInt(Math.floor(num * 1e6))\n case 'DAI':\n return BigInt(Math.floor(num * 1e18))\n default:\n return null\n }\n}\n","import type { Address } from 'viem'\n\nexport const TOKENS: Record<string, Record<string, Address>> = {\n sepolia: {\n USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n WETH: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',\n DAI: '0x68194a729C2450ad26072b3D33ADaCbcef39D574',\n },\n 'base-sepolia': {\n USDC: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n WETH: '0x4200000000000000000000000000000000000006',\n },\n base: {\n USDC: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n WETH: '0x4200000000000000000000000000000000000006',\n DAI: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',\n USDbC: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',\n },\n}\n\nexport const ERC20_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'approve',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [],\n name: 'decimals',\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [],\n name: 'symbol',\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n","import { http } from 'viem'\nimport type { Address, Hash, Hex } from 'viem'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport { createSmartAccountClient } from 'permissionless'\nimport { toTrustSmartAccount } from 'permissionless/accounts'\n\nimport type {\n AgentConfig,\n BarzAgent,\n TransactionRequest,\n TransactionReceipt,\n AgentPermissions,\n} from './types'\nimport { createClients } from './client'\nimport { PermissionManager } from '../permissions/permissions'\nimport { BarzKitError, ConfigError, FrozenError, humanizeError, TransactionError } from '../utils/errors'\nimport { ERC20_ABI } from '../utils/constants'\n\n/**\n * Create a Barz agent wallet.\n *\n * @example\n * ```ts\n * const agent = await createBarzAgent({\n * chain: 'sepolia',\n * owner: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n * pimlico: { apiKey: 'pim_...' },\n * })\n *\n * console.log('Agent address:', agent.address)\n * ```\n */\nexport async function createBarzAgent(config: AgentConfig): Promise<BarzAgent> {\n validateConfig(config)\n\n const { publicClient, pimlicoClient, chainConfig, bundlerUrl } = createClients(config)\n const ownerAccount = privateKeyToAccount(config.owner)\n\n const smartAccount = await toTrustSmartAccount({\n client: publicClient,\n owner: ownerAccount,\n index: config.index ?? 0n,\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n const gasless = config.gasless !== false\n\n const smartAccountClient = createSmartAccountClient({\n account: smartAccount,\n chain: chainConfig.chain,\n bundlerTransport: http(bundlerUrl),\n ...(gasless\n ? {\n paymaster: pimlicoClient,\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }\n : {\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }),\n })\n\n if (config.chain === 'base') {\n console.warn('\\u26a0\\ufe0f Using Base mainnet \\u2014 real funds at risk')\n }\n\n const permissionManager = new PermissionManager(config.permissions)\n let frozen = false\n\n const agent: BarzAgent = {\n address: smartAccount.address,\n chain: config.chain,\n owner: ownerAccount.address,\n\n async sendTransaction(tx: TransactionRequest): Promise<Hash> {\n if (frozen) throw new FrozenError()\n permissionManager.validate(tx)\n\n try {\n const hash = await smartAccountClient.sendTransaction({\n to: tx.to,\n value: tx.value ?? 0n,\n data: tx.data ?? '0x',\n })\n\n if (tx.value) permissionManager.recordSpend(tx.value)\n return hash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async batchTransactions(txs: TransactionRequest[]): Promise<Hash> {\n if (frozen) throw new FrozenError()\n if (txs.length === 0) {\n throw new BarzKitError(\n 'batchTransactions requires at least one transaction.',\n 'BATCH_EMPTY',\n )\n }\n\n for (const tx of txs) {\n permissionManager.validate(tx)\n }\n\n try {\n const userOpHash = await smartAccountClient.sendUserOperation({\n calls: txs.map((tx) => ({\n to: tx.to,\n value: tx.value ?? 0n,\n data: tx.data ?? ('0x' as Hex),\n })),\n })\n\n const receipt = await smartAccountClient.waitForUserOperationReceipt({\n hash: userOpHash,\n })\n\n const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n)\n if (totalValue > 0n) permissionManager.recordSpend(totalValue)\n\n return receipt.receipt.transactionHash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async getBalance(token?: Address): Promise<bigint> {\n try {\n if (!token) {\n return await publicClient.getBalance({ address: smartAccount.address })\n }\n\n const balance = await publicClient.readContract({\n address: token,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [smartAccount.address],\n })\n\n return balance as bigint\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async waitForTransaction(hash: Hash): Promise<TransactionReceipt> {\n try {\n const receipt = await publicClient.waitForTransactionReceipt({ hash })\n return {\n transactionHash: receipt.transactionHash,\n blockNumber: receipt.blockNumber,\n status: receipt.status,\n gasUsed: receipt.gasUsed,\n }\n } catch (error) {\n throw new TransactionError(\n `Failed waiting for transaction ${hash}: ${error instanceof Error ? error.message : error}`,\n hash,\n )\n }\n },\n\n getExplorerUrl(hash: Hash): string {\n return `${chainConfig.explorerUrl}/tx/${hash}`\n },\n\n getPermissions(): AgentPermissions {\n return permissionManager.permissions\n },\n\n updatePermissions(permissions: Partial<AgentPermissions>): void {\n permissionManager.update(permissions)\n },\n\n async freeze(): Promise<Hash> {\n frozen = true\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async unfreeze(): Promise<Hash> {\n frozen = false\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async isActive(): Promise<boolean> {\n return !frozen\n },\n }\n\n return agent\n}\n\nfunction validateConfig(config: AgentConfig): void {\n if (!config) throw new ConfigError('Agent config is required.')\n\n if (!config.chain) {\n throw new ConfigError('Missing \"chain\". Supported: sepolia, base-sepolia, base.')\n }\n if (!config.owner) {\n throw new ConfigError('Missing \"owner\". Provide a hex private key.')\n }\n if (!config.owner.startsWith('0x') || config.owner.length !== 66) {\n throw new ConfigError(\n 'Invalid \"owner\" private key. Must be a 32-byte hex string starting with \"0x\" (66 chars total).',\n )\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError('Missing \"pimlico.apiKey\". Get a free key at https://dashboard.pimlico.io')\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -59,6 +59,8 @@ interface BarzAgent {
|
|
|
59
59
|
waitForTransaction(hash: Hash): Promise<TransactionReceipt>;
|
|
60
60
|
getPermissions(): AgentPermissions;
|
|
61
61
|
updatePermissions(permissions: Partial<AgentPermissions>): void;
|
|
62
|
+
/** Get block explorer URL for a transaction hash */
|
|
63
|
+
getExplorerUrl(hash: Hash): string;
|
|
62
64
|
freeze(): Promise<Hash>;
|
|
63
65
|
unfreeze(): Promise<Hash>;
|
|
64
66
|
isActive(): Promise<boolean>;
|
|
@@ -70,6 +72,8 @@ interface ChainConfig {
|
|
|
70
72
|
paymasterUrl: string;
|
|
71
73
|
entryPointAddress: Address;
|
|
72
74
|
entryPointVersion: '0.6';
|
|
75
|
+
/** Block explorer base URL (e.g., 'https://sepolia.etherscan.io') */
|
|
76
|
+
explorerUrl: string;
|
|
73
77
|
}
|
|
74
78
|
interface TransactionReceipt {
|
|
75
79
|
transactionHash: Hash;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,8 @@ interface BarzAgent {
|
|
|
59
59
|
waitForTransaction(hash: Hash): Promise<TransactionReceipt>;
|
|
60
60
|
getPermissions(): AgentPermissions;
|
|
61
61
|
updatePermissions(permissions: Partial<AgentPermissions>): void;
|
|
62
|
+
/** Get block explorer URL for a transaction hash */
|
|
63
|
+
getExplorerUrl(hash: Hash): string;
|
|
62
64
|
freeze(): Promise<Hash>;
|
|
63
65
|
unfreeze(): Promise<Hash>;
|
|
64
66
|
isActive(): Promise<boolean>;
|
|
@@ -70,6 +72,8 @@ interface ChainConfig {
|
|
|
70
72
|
paymasterUrl: string;
|
|
71
73
|
entryPointAddress: Address;
|
|
72
74
|
entryPointVersion: '0.6';
|
|
75
|
+
/** Block explorer base URL (e.g., 'https://sepolia.etherscan.io') */
|
|
76
|
+
explorerUrl: string;
|
|
73
77
|
}
|
|
74
78
|
interface TransactionReceipt {
|
|
75
79
|
transactionHash: Hash;
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,8 @@ var CHAIN_CONFIGS = {
|
|
|
14
14
|
bundlerUrl: "https://api.pimlico.io/v2/sepolia/rpc",
|
|
15
15
|
paymasterUrl: "https://api.pimlico.io/v2/sepolia/rpc",
|
|
16
16
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
17
|
-
entryPointVersion: "0.6"
|
|
17
|
+
entryPointVersion: "0.6",
|
|
18
|
+
explorerUrl: "https://sepolia.etherscan.io"
|
|
18
19
|
},
|
|
19
20
|
"base-sepolia": {
|
|
20
21
|
chain: baseSepolia,
|
|
@@ -22,7 +23,8 @@ var CHAIN_CONFIGS = {
|
|
|
22
23
|
bundlerUrl: "https://api.pimlico.io/v2/base-sepolia/rpc",
|
|
23
24
|
paymasterUrl: "https://api.pimlico.io/v2/base-sepolia/rpc",
|
|
24
25
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
25
|
-
entryPointVersion: "0.6"
|
|
26
|
+
entryPointVersion: "0.6",
|
|
27
|
+
explorerUrl: "https://sepolia.basescan.org"
|
|
26
28
|
},
|
|
27
29
|
base: {
|
|
28
30
|
chain: base,
|
|
@@ -30,7 +32,8 @@ var CHAIN_CONFIGS = {
|
|
|
30
32
|
bundlerUrl: "https://api.pimlico.io/v2/base/rpc",
|
|
31
33
|
paymasterUrl: "https://api.pimlico.io/v2/base/rpc",
|
|
32
34
|
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
33
|
-
entryPointVersion: "0.6"
|
|
35
|
+
entryPointVersion: "0.6",
|
|
36
|
+
explorerUrl: "https://basescan.org"
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
function getChainConfig(chain) {
|
|
@@ -344,6 +347,9 @@ async function createBarzAgent(config) {
|
|
|
344
347
|
}
|
|
345
348
|
}
|
|
346
349
|
});
|
|
350
|
+
if (config.chain === "base") {
|
|
351
|
+
console.warn("\u26A0\uFE0F Using Base mainnet \u2014 real funds at risk");
|
|
352
|
+
}
|
|
347
353
|
const permissionManager = new PermissionManager(config.permissions);
|
|
348
354
|
let frozen = false;
|
|
349
355
|
const agent = {
|
|
@@ -368,20 +374,28 @@ async function createBarzAgent(config) {
|
|
|
368
374
|
async batchTransactions(txs) {
|
|
369
375
|
if (frozen) throw new FrozenError();
|
|
370
376
|
if (txs.length === 0) {
|
|
371
|
-
throw new
|
|
377
|
+
throw new BarzKitError(
|
|
378
|
+
"batchTransactions requires at least one transaction.",
|
|
379
|
+
"BATCH_EMPTY"
|
|
380
|
+
);
|
|
372
381
|
}
|
|
373
382
|
for (const tx of txs) {
|
|
374
383
|
permissionManager.validate(tx);
|
|
375
384
|
}
|
|
376
385
|
try {
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
386
|
+
const userOpHash = await smartAccountClient.sendUserOperation({
|
|
387
|
+
calls: txs.map((tx) => ({
|
|
388
|
+
to: tx.to,
|
|
389
|
+
value: tx.value ?? 0n,
|
|
390
|
+
data: tx.data ?? "0x"
|
|
391
|
+
}))
|
|
392
|
+
});
|
|
393
|
+
const receipt = await smartAccountClient.waitForUserOperationReceipt({
|
|
394
|
+
hash: userOpHash
|
|
381
395
|
});
|
|
382
396
|
const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n);
|
|
383
397
|
if (totalValue > 0n) permissionManager.recordSpend(totalValue);
|
|
384
|
-
return
|
|
398
|
+
return receipt.receipt.transactionHash;
|
|
385
399
|
} catch (error) {
|
|
386
400
|
throw humanizeError(error);
|
|
387
401
|
}
|
|
@@ -418,6 +432,9 @@ async function createBarzAgent(config) {
|
|
|
418
432
|
);
|
|
419
433
|
}
|
|
420
434
|
},
|
|
435
|
+
getExplorerUrl(hash) {
|
|
436
|
+
return `${chainConfig.explorerUrl}/tx/${hash}`;
|
|
437
|
+
},
|
|
421
438
|
getPermissions() {
|
|
422
439
|
return permissionManager.permissions;
|
|
423
440
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/chains/chains.ts","../src/utils/errors.ts","../src/core/client.ts","../src/permissions/permissions.ts","../src/utils/constants.ts","../src/core/account.ts"],"names":["entryPoint06Address","http"],"mappings":";;;;;;;;;AAGO,IAAM,aAAA,GAAqD;AAAA,EAChE,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,6CAAA;AAAA,IACR,UAAA,EAAY,uCAAA;AAAA,IACZ,YAAA,EAAc,uCAAA;AAAA,IACd,iBAAA,EAAmB,4CAAA;AAAA,IACnB,iBAAA,EAAmB;AAAA,GACrB;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,WAAA;AAAA,IACP,MAAA,EAAQ,0BAAA;AAAA,IACR,UAAA,EAAY,4CAAA;AAAA,IACZ,YAAA,EAAc,4CAAA;AAAA,IACd,iBAAA,EAAmB,4CAAA;AAAA,IACnB,iBAAA,EAA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A,IAAI,CAAC,MAAA,CAAO,OAAA,EAAS,MAAA,EAAQ;AAC3B,IAAA,MAAM,IAAI,YAAY,0EAA0E,CAAA;AAAA,EAClG;AACF","file":"index.js","sourcesContent":["import { sepolia, baseSepolia, base } from 'viem/chains'\nimport type { ChainConfig, SupportedChain } from '../core/types'\n\nexport const CHAIN_CONFIGS: Record<SupportedChain, ChainConfig> = {\n sepolia: {\n chain: sepolia,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n bundlerUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n },\n 'base-sepolia': {\n chain: baseSepolia,\n rpcUrl: 'https://sepolia.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n },\n base: {\n chain: base,\n rpcUrl: 'https://mainnet.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n },\n}\n\nexport function getChainConfig(chain: SupportedChain): ChainConfig {\n const config = CHAIN_CONFIGS[chain]\n if (!config) {\n const supported = Object.keys(CHAIN_CONFIGS).join(', ')\n throw new Error(`Unsupported chain: \"${chain}\". Supported: ${supported}`)\n }\n return config\n}\n\nexport function buildBundlerUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.bundlerUrl}?apikey=${apiKey}`\n}\n\nexport function buildPaymasterUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.paymasterUrl}?apikey=${apiKey}`\n}\n","export class BarzKitError extends Error {\n public readonly code: string\n\n constructor(message: string, code: string) {\n super(message)\n this.name = 'BarzKitError'\n this.code = code\n }\n}\n\nexport class ConfigError extends BarzKitError {\n constructor(message: string) {\n super(message, 'CONFIG_ERROR')\n this.name = 'ConfigError'\n }\n}\n\nexport class PermissionError extends BarzKitError {\n constructor(message: string) {\n super(message, 'PERMISSION_DENIED')\n this.name = 'PermissionError'\n }\n}\n\nexport class FrozenError extends BarzKitError {\n constructor() {\n super(\n 'Agent wallet is frozen. Call agent.unfreeze() to resume operation.',\n 'AGENT_FROZEN',\n )\n this.name = 'FrozenError'\n }\n}\n\nexport class TransactionError extends BarzKitError {\n public readonly txHash?: string\n\n constructor(message: string, txHash?: string) {\n super(message, 'TRANSACTION_FAILED')\n this.name = 'TransactionError'\n this.txHash = txHash\n }\n}\n\nexport class BundlerError extends BarzKitError {\n constructor(message: string) {\n super(message, 'BUNDLER_ERROR')\n this.name = 'BundlerError'\n }\n}\n\nexport function humanizeError(error: unknown): BarzKitError {\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('AA21')) {\n return new TransactionError(\n 'Smart account has insufficient funds to pay for gas. ' +\n 'Send ETH to the agent wallet address, or enable gasless mode.',\n )\n }\n\n if (message.includes('AA25')) {\n return new TransactionError(\n 'Invalid signature. The agent key may not be authorized for this account.',\n )\n }\n\n if (message.includes('AA31')) {\n return new TransactionError(\n 'Paymaster deposit too low. The paymaster may be out of funds. ' +\n 'Try again later or switch to self-funded mode.',\n )\n }\n\n if (message.includes('AA33')) {\n return new TransactionError(\n 'Transaction reverted during validation. The calldata may be invalid ' +\n 'or the target contract may have rejected the call.',\n )\n }\n\n if (message.includes('AA40') || message.includes('AA41')) {\n return new TransactionError(\n 'Paymaster validation failed. The paymaster may not support this operation.',\n )\n }\n\n if (message.includes('insufficient funds')) {\n return new TransactionError(\n 'Insufficient funds in the agent wallet. Check balance with agent.getBalance().',\n )\n }\n\n return new BarzKitError(`Transaction failed: ${message}`, 'UNKNOWN_ERROR')\n}\n","import { createPublicClient, http } from 'viem'\nimport type { PublicClient, HttpTransport, Chain } from 'viem'\nimport { createPimlicoClient } from 'permissionless/clients/pimlico'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport type { AgentConfig, ChainConfig } from './types'\nimport { getChainConfig, buildBundlerUrl } from '../chains/chains'\nimport { ConfigError } from '../utils/errors'\n\nexport interface BarzClients {\n publicClient: PublicClient<HttpTransport, Chain>\n pimlicoClient: ReturnType<typeof createPimlicoClient>\n chainConfig: ChainConfig\n bundlerUrl: string\n}\n\nexport function createClients(config: AgentConfig): BarzClients {\n if (!config.chain) {\n throw new ConfigError('Missing required field: \"chain\". Example: { chain: \"sepolia\" }')\n }\n if (!config.owner) {\n throw new ConfigError('Missing required field: \"owner\". Provide a hex private key.')\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError(\n 'Missing required field: \"pimlico.apiKey\". ' +\n 'Get a free API key at https://dashboard.pimlico.io',\n )\n }\n\n const chainConfig = getChainConfig(config.chain)\n const rpcUrl = config.rpcUrl || chainConfig.rpcUrl\n const bundlerUrl = buildBundlerUrl(chainConfig, config.pimlico.apiKey)\n\n const publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n })\n\n const pimlicoClient = createPimlicoClient({\n transport: http(bundlerUrl),\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n return {\n publicClient: publicClient as PublicClient<HttpTransport, Chain>,\n pimlicoClient,\n chainConfig,\n bundlerUrl,\n }\n}\n","import type { AgentPermissions, TransactionRequest } from '../core/types'\nimport { PermissionError } from '../utils/errors'\n\nexport class PermissionManager {\n private _permissions: AgentPermissions\n private _dailySpent: bigint = 0n\n private _dailyResetTime: number = Date.now()\n\n constructor(permissions: AgentPermissions = {}) {\n this._permissions = { ...permissions }\n }\n\n get permissions(): AgentPermissions {\n return { ...this._permissions }\n }\n\n update(permissions: Partial<AgentPermissions>): void {\n this._permissions = { ...this._permissions, ...permissions }\n }\n\n validate(tx: TransactionRequest): void {\n const p = this._permissions\n\n // Check allowed contracts\n if (p.allowedContracts && p.allowedContracts.length > 0) {\n const target = tx.to.toLowerCase()\n const allowed = p.allowedContracts.map((a) => a.toLowerCase())\n if (!allowed.includes(target)) {\n throw new PermissionError(\n `Target contract ${tx.to} is not in the allowed list. ` +\n `Allowed: ${p.allowedContracts.join(', ')}`,\n )\n }\n }\n\n // Check time window\n if (p.timeWindow) {\n const now = new Date()\n const hours = now.getUTCHours()\n const minutes = now.getUTCMinutes()\n const currentTime = hours * 60 + minutes\n\n const [startH, startM] = p.timeWindow.start.split(':').map(Number)\n const [endH, endM] = p.timeWindow.end.split(':').map(Number)\n const startTime = startH * 60 + startM\n const endTime = endH * 60 + endM\n\n if (currentTime < startTime || currentTime > endTime) {\n throw new PermissionError(\n `Transaction outside allowed time window. ` +\n `Allowed: ${p.timeWindow.start} - ${p.timeWindow.end} UTC. ` +\n `Current: ${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')} UTC.`,\n )\n }\n }\n\n // Check per-transaction amount limit\n if (p.maxAmountPerTx && tx.value) {\n const limit = parseHumanAmount(p.maxAmountPerTx)\n if (limit !== null && tx.value > limit) {\n throw new PermissionError(\n `Transaction value ${tx.value} exceeds per-transaction limit of ${p.maxAmountPerTx}.`,\n )\n }\n }\n\n // Check daily spend\n if (p.maxDailySpend && tx.value) {\n this._resetDailyIfNeeded()\n const limit = parseHumanAmount(p.maxDailySpend)\n if (limit !== null && this._dailySpent + tx.value > limit) {\n throw new PermissionError(\n `Transaction would exceed daily spend limit of ${p.maxDailySpend}. ` +\n `Already spent today: ${this._dailySpent}. Requested: ${tx.value}.`,\n )\n }\n }\n }\n\n recordSpend(value: bigint): void {\n this._resetDailyIfNeeded()\n this._dailySpent += value\n }\n\n private _resetDailyIfNeeded(): void {\n const now = Date.now()\n const ONE_DAY = 24 * 60 * 60 * 1000\n if (now - this._dailyResetTime > ONE_DAY) {\n this._dailySpent = 0n\n this._dailyResetTime = now\n }\n }\n}\n\nfunction parseHumanAmount(amount: string): bigint | null {\n const parts = amount.trim().split(/\\s+/)\n const num = parseFloat(parts[0])\n if (isNaN(num)) return null\n\n const unit = parts[1]?.toUpperCase() || 'WEI'\n\n switch (unit) {\n case 'ETH':\n return BigInt(Math.floor(num * 1e18))\n case 'GWEI':\n return BigInt(Math.floor(num * 1e9))\n case 'WEI':\n return BigInt(Math.floor(num))\n case 'USDC':\n case 'USDT':\n return BigInt(Math.floor(num * 1e6))\n case 'DAI':\n return BigInt(Math.floor(num * 1e18))\n default:\n return null\n }\n}\n","import type { Address } from 'viem'\n\nexport const TOKENS: Record<string, Record<string, Address>> = {\n sepolia: {\n USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n WETH: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',\n DAI: '0x68194a729C2450ad26072b3D33ADaCbcef39D574',\n },\n 'base-sepolia': {\n USDC: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n WETH: '0x4200000000000000000000000000000000000006',\n },\n base: {\n USDC: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n WETH: '0x4200000000000000000000000000000000000006',\n DAI: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',\n USDbC: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',\n },\n}\n\nexport const ERC20_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'approve',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [],\n name: 'decimals',\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [],\n name: 'symbol',\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n","import { http } from 'viem'\nimport type { Address, Hash, Hex } from 'viem'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport { createSmartAccountClient } from 'permissionless'\nimport { toTrustSmartAccount } from 'permissionless/accounts'\n\nimport type {\n AgentConfig,\n BarzAgent,\n TransactionRequest,\n TransactionReceipt,\n AgentPermissions,\n} from './types'\nimport { createClients } from './client'\nimport { PermissionManager } from '../permissions/permissions'\nimport { ConfigError, FrozenError, humanizeError, TransactionError } from '../utils/errors'\nimport { ERC20_ABI } from '../utils/constants'\n\n/**\n * Create a Barz agent wallet.\n *\n * @example\n * ```ts\n * const agent = await createBarzAgent({\n * chain: 'sepolia',\n * owner: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n * pimlico: { apiKey: 'pim_...' },\n * })\n *\n * console.log('Agent address:', agent.address)\n * ```\n */\nexport async function createBarzAgent(config: AgentConfig): Promise<BarzAgent> {\n validateConfig(config)\n\n const { publicClient, pimlicoClient, chainConfig, bundlerUrl } = createClients(config)\n const ownerAccount = privateKeyToAccount(config.owner)\n\n const smartAccount = await toTrustSmartAccount({\n client: publicClient,\n owner: ownerAccount,\n index: config.index ?? 0n,\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n const gasless = config.gasless !== false\n\n const smartAccountClient = createSmartAccountClient({\n account: smartAccount,\n chain: chainConfig.chain,\n bundlerTransport: http(bundlerUrl),\n ...(gasless\n ? {\n paymaster: pimlicoClient,\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }\n : {\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }),\n })\n\n const permissionManager = new PermissionManager(config.permissions)\n let frozen = false\n\n const agent: BarzAgent = {\n address: smartAccount.address,\n chain: config.chain,\n owner: ownerAccount.address,\n\n async sendTransaction(tx: TransactionRequest): Promise<Hash> {\n if (frozen) throw new FrozenError()\n permissionManager.validate(tx)\n\n try {\n const hash = await smartAccountClient.sendTransaction({\n to: tx.to,\n value: tx.value ?? 0n,\n data: tx.data ?? '0x',\n })\n\n if (tx.value) permissionManager.recordSpend(tx.value)\n return hash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async batchTransactions(txs: TransactionRequest[]): Promise<Hash> {\n if (frozen) throw new FrozenError()\n if (txs.length === 0) {\n throw new ConfigError('batchTransactions requires at least one transaction.')\n }\n\n for (const tx of txs) {\n permissionManager.validate(tx)\n }\n\n try {\n // TODO: actual batch encoding when permissionless.js supports it\n const hash = await smartAccountClient.sendTransaction({\n to: txs[0].to,\n value: txs[0].value ?? 0n,\n data: txs[0].data ?? ('0x' as Hex),\n })\n\n const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n)\n if (totalValue > 0n) permissionManager.recordSpend(totalValue)\n\n return hash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async getBalance(token?: Address): Promise<bigint> {\n try {\n if (!token) {\n return await publicClient.getBalance({ address: smartAccount.address })\n }\n\n const balance = await publicClient.readContract({\n address: token,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [smartAccount.address],\n })\n\n return balance as bigint\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async waitForTransaction(hash: Hash): Promise<TransactionReceipt> {\n try {\n const receipt = await publicClient.waitForTransactionReceipt({ hash })\n return {\n transactionHash: receipt.transactionHash,\n blockNumber: receipt.blockNumber,\n status: receipt.status,\n gasUsed: receipt.gasUsed,\n }\n } catch (error) {\n throw new TransactionError(\n `Failed waiting for transaction ${hash}: ${error instanceof Error ? error.message : error}`,\n hash,\n )\n }\n },\n\n getPermissions(): AgentPermissions {\n return permissionManager.permissions\n },\n\n updatePermissions(permissions: Partial<AgentPermissions>): void {\n permissionManager.update(permissions)\n },\n\n async freeze(): Promise<Hash> {\n frozen = true\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async unfreeze(): Promise<Hash> {\n frozen = false\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async isActive(): Promise<boolean> {\n return !frozen\n },\n }\n\n return agent\n}\n\nfunction validateConfig(config: AgentConfig): void {\n if (!config) throw new ConfigError('Agent config is required.')\n\n if (!config.chain) {\n throw new ConfigError('Missing \"chain\". Supported: sepolia, base-sepolia, base.')\n }\n if (!config.owner) {\n throw new ConfigError('Missing \"owner\". Provide a hex private key.')\n }\n if (!config.owner.startsWith('0x') || config.owner.length !== 66) {\n throw new ConfigError(\n 'Invalid \"owner\" private key. Must be a 32-byte hex string starting with \"0x\" (66 chars total).',\n )\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError('Missing \"pimlico.apiKey\". Get a free key at https://dashboard.pimlico.io')\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/chains/chains.ts","../src/utils/errors.ts","../src/core/client.ts","../src/permissions/permissions.ts","../src/utils/constants.ts","../src/core/account.ts"],"names":["entryPoint06Address","http"],"mappings":";;;;;;;;;AAGO,IAAM,aAAA,GAAqD;AAAA,EAChE,OAAA,EAAS;AAAA,IACP,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,6CAAA;AAAA,IACR,UAAA,EAAY,uCAAA;AAAA,IACZ,YAAA,EAAc,uCAAA;AAAA,IACd,iBAAA,EAAmB,4CAAA;AAAA,IACnB,iBAAA,EAAmB,KAAA;AAAA,IACnB,WAAA,EAAa;AAAA,GACf;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAO,WAAA;AAAA,IACP,MAAA,EAAQ,0BAAA;AAAA,IACR,UAAA,EAAY,4CAAA;AAAA,IACZ,YAAA,EAAc,4CAAA;AAAA,IACd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EAAA,OAAO,KAAA;AACT;AAEA,SAAS,eAAe,MAAA,EAA2B;AACjD,EAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,YAAY,2BAA2B,CAAA;AAE9D,EAAA,IAAI,CAAC,OAAO,KAAA,EAAO;AACjB,IAAA,MAAM,IAAI,YAAY,0DAA0D,CAAA;AAAA,EAClF;AACA,EAAA,IAAI,CAAC,OAAO,KAAA,EAAO;AACjB,IAAA,MAAM,IAAI,YAAY,6CAA6C,CAAA;AAAA,EACrE;AACA,EAAA,IAAI,CAAC,OAAO,KAAA,CAAM,UAAA,CAAW,IAAI,CAAA,IAAK,MAAA,CAAO,KAAA,CAAM,MAAA,KAAW,EAAA,EAAI;AAChE,IAAA,MAAM,IAAI,WAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,CAAC,MAAA,CAAO,OAAA,EAAS,MAAA,EAAQ;AAC3B,IAAA,MAAM,IAAI,YAAY,0EAA0E,CAAA;AAAA,EAClG;AACF","file":"index.js","sourcesContent":["import { sepolia, baseSepolia, base } from 'viem/chains'\nimport type { ChainConfig, SupportedChain } from '../core/types'\n\nexport const CHAIN_CONFIGS: Record<SupportedChain, ChainConfig> = {\n sepolia: {\n chain: sepolia,\n rpcUrl: 'https://ethereum-sepolia-rpc.publicnode.com',\n bundlerUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n explorerUrl: 'https://sepolia.etherscan.io',\n },\n 'base-sepolia': {\n chain: baseSepolia,\n rpcUrl: 'https://sepolia.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base-sepolia/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n explorerUrl: 'https://sepolia.basescan.org',\n },\n base: {\n chain: base,\n rpcUrl: 'https://mainnet.base.org',\n bundlerUrl: 'https://api.pimlico.io/v2/base/rpc',\n paymasterUrl: 'https://api.pimlico.io/v2/base/rpc',\n entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',\n entryPointVersion: '0.6',\n explorerUrl: 'https://basescan.org',\n },\n}\n\nexport function getChainConfig(chain: SupportedChain): ChainConfig {\n const config = CHAIN_CONFIGS[chain]\n if (!config) {\n const supported = Object.keys(CHAIN_CONFIGS).join(', ')\n throw new Error(`Unsupported chain: \"${chain}\". Supported: ${supported}`)\n }\n return config\n}\n\nexport function buildBundlerUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.bundlerUrl}?apikey=${apiKey}`\n}\n\nexport function buildPaymasterUrl(chainConfig: ChainConfig, apiKey: string): string {\n return `${chainConfig.paymasterUrl}?apikey=${apiKey}`\n}\n","export class BarzKitError extends Error {\n public readonly code: string\n\n constructor(message: string, code: string) {\n super(message)\n this.name = 'BarzKitError'\n this.code = code\n }\n}\n\nexport class ConfigError extends BarzKitError {\n constructor(message: string) {\n super(message, 'CONFIG_ERROR')\n this.name = 'ConfigError'\n }\n}\n\nexport class PermissionError extends BarzKitError {\n constructor(message: string) {\n super(message, 'PERMISSION_DENIED')\n this.name = 'PermissionError'\n }\n}\n\nexport class FrozenError extends BarzKitError {\n constructor() {\n super(\n 'Agent wallet is frozen. Call agent.unfreeze() to resume operation.',\n 'AGENT_FROZEN',\n )\n this.name = 'FrozenError'\n }\n}\n\nexport class TransactionError extends BarzKitError {\n public readonly txHash?: string\n\n constructor(message: string, txHash?: string) {\n super(message, 'TRANSACTION_FAILED')\n this.name = 'TransactionError'\n this.txHash = txHash\n }\n}\n\nexport class BundlerError extends BarzKitError {\n constructor(message: string) {\n super(message, 'BUNDLER_ERROR')\n this.name = 'BundlerError'\n }\n}\n\nexport function humanizeError(error: unknown): BarzKitError {\n const message = error instanceof Error ? error.message : String(error)\n\n if (message.includes('AA21')) {\n return new TransactionError(\n 'Smart account has insufficient funds to pay for gas. ' +\n 'Send ETH to the agent wallet address, or enable gasless mode.',\n )\n }\n\n if (message.includes('AA25')) {\n return new TransactionError(\n 'Invalid signature. The agent key may not be authorized for this account.',\n )\n }\n\n if (message.includes('AA31')) {\n return new TransactionError(\n 'Paymaster deposit too low. The paymaster may be out of funds. ' +\n 'Try again later or switch to self-funded mode.',\n )\n }\n\n if (message.includes('AA33')) {\n return new TransactionError(\n 'Transaction reverted during validation. The calldata may be invalid ' +\n 'or the target contract may have rejected the call.',\n )\n }\n\n if (message.includes('AA40') || message.includes('AA41')) {\n return new TransactionError(\n 'Paymaster validation failed. The paymaster may not support this operation.',\n )\n }\n\n if (message.includes('insufficient funds')) {\n return new TransactionError(\n 'Insufficient funds in the agent wallet. Check balance with agent.getBalance().',\n )\n }\n\n return new BarzKitError(`Transaction failed: ${message}`, 'UNKNOWN_ERROR')\n}\n","import { createPublicClient, http } from 'viem'\nimport type { PublicClient, HttpTransport, Chain } from 'viem'\nimport { createPimlicoClient } from 'permissionless/clients/pimlico'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport type { AgentConfig, ChainConfig } from './types'\nimport { getChainConfig, buildBundlerUrl } from '../chains/chains'\nimport { ConfigError } from '../utils/errors'\n\nexport interface BarzClients {\n publicClient: PublicClient<HttpTransport, Chain>\n pimlicoClient: ReturnType<typeof createPimlicoClient>\n chainConfig: ChainConfig\n bundlerUrl: string\n}\n\nexport function createClients(config: AgentConfig): BarzClients {\n if (!config.chain) {\n throw new ConfigError('Missing required field: \"chain\". Example: { chain: \"sepolia\" }')\n }\n if (!config.owner) {\n throw new ConfigError('Missing required field: \"owner\". Provide a hex private key.')\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError(\n 'Missing required field: \"pimlico.apiKey\". ' +\n 'Get a free API key at https://dashboard.pimlico.io',\n )\n }\n\n const chainConfig = getChainConfig(config.chain)\n const rpcUrl = config.rpcUrl || chainConfig.rpcUrl\n const bundlerUrl = buildBundlerUrl(chainConfig, config.pimlico.apiKey)\n\n const publicClient = createPublicClient({\n chain: chainConfig.chain,\n transport: http(rpcUrl),\n })\n\n const pimlicoClient = createPimlicoClient({\n transport: http(bundlerUrl),\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n return {\n publicClient: publicClient as PublicClient<HttpTransport, Chain>,\n pimlicoClient,\n chainConfig,\n bundlerUrl,\n }\n}\n","import type { AgentPermissions, TransactionRequest } from '../core/types'\nimport { PermissionError } from '../utils/errors'\n\nexport class PermissionManager {\n private _permissions: AgentPermissions\n private _dailySpent: bigint = 0n\n private _dailyResetTime: number = Date.now()\n\n constructor(permissions: AgentPermissions = {}) {\n this._permissions = { ...permissions }\n }\n\n get permissions(): AgentPermissions {\n return { ...this._permissions }\n }\n\n update(permissions: Partial<AgentPermissions>): void {\n this._permissions = { ...this._permissions, ...permissions }\n }\n\n validate(tx: TransactionRequest): void {\n const p = this._permissions\n\n // Check allowed contracts\n if (p.allowedContracts && p.allowedContracts.length > 0) {\n const target = tx.to.toLowerCase()\n const allowed = p.allowedContracts.map((a) => a.toLowerCase())\n if (!allowed.includes(target)) {\n throw new PermissionError(\n `Target contract ${tx.to} is not in the allowed list. ` +\n `Allowed: ${p.allowedContracts.join(', ')}`,\n )\n }\n }\n\n // Check time window\n if (p.timeWindow) {\n const now = new Date()\n const hours = now.getUTCHours()\n const minutes = now.getUTCMinutes()\n const currentTime = hours * 60 + minutes\n\n const [startH, startM] = p.timeWindow.start.split(':').map(Number)\n const [endH, endM] = p.timeWindow.end.split(':').map(Number)\n const startTime = startH * 60 + startM\n const endTime = endH * 60 + endM\n\n if (currentTime < startTime || currentTime > endTime) {\n throw new PermissionError(\n `Transaction outside allowed time window. ` +\n `Allowed: ${p.timeWindow.start} - ${p.timeWindow.end} UTC. ` +\n `Current: ${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')} UTC.`,\n )\n }\n }\n\n // Check per-transaction amount limit\n if (p.maxAmountPerTx && tx.value) {\n const limit = parseHumanAmount(p.maxAmountPerTx)\n if (limit !== null && tx.value > limit) {\n throw new PermissionError(\n `Transaction value ${tx.value} exceeds per-transaction limit of ${p.maxAmountPerTx}.`,\n )\n }\n }\n\n // Check daily spend\n if (p.maxDailySpend && tx.value) {\n this._resetDailyIfNeeded()\n const limit = parseHumanAmount(p.maxDailySpend)\n if (limit !== null && this._dailySpent + tx.value > limit) {\n throw new PermissionError(\n `Transaction would exceed daily spend limit of ${p.maxDailySpend}. ` +\n `Already spent today: ${this._dailySpent}. Requested: ${tx.value}.`,\n )\n }\n }\n }\n\n recordSpend(value: bigint): void {\n this._resetDailyIfNeeded()\n this._dailySpent += value\n }\n\n private _resetDailyIfNeeded(): void {\n const now = Date.now()\n const ONE_DAY = 24 * 60 * 60 * 1000\n if (now - this._dailyResetTime > ONE_DAY) {\n this._dailySpent = 0n\n this._dailyResetTime = now\n }\n }\n}\n\nfunction parseHumanAmount(amount: string): bigint | null {\n const parts = amount.trim().split(/\\s+/)\n const num = parseFloat(parts[0])\n if (isNaN(num)) return null\n\n const unit = parts[1]?.toUpperCase() || 'WEI'\n\n switch (unit) {\n case 'ETH':\n return BigInt(Math.floor(num * 1e18))\n case 'GWEI':\n return BigInt(Math.floor(num * 1e9))\n case 'WEI':\n return BigInt(Math.floor(num))\n case 'USDC':\n case 'USDT':\n return BigInt(Math.floor(num * 1e6))\n case 'DAI':\n return BigInt(Math.floor(num * 1e18))\n default:\n return null\n }\n}\n","import type { Address } from 'viem'\n\nexport const TOKENS: Record<string, Record<string, Address>> = {\n sepolia: {\n USDC: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',\n WETH: '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',\n DAI: '0x68194a729C2450ad26072b3D33ADaCbcef39D574',\n },\n 'base-sepolia': {\n USDC: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n WETH: '0x4200000000000000000000000000000000000006',\n },\n base: {\n USDC: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',\n WETH: '0x4200000000000000000000000000000000000006',\n DAI: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',\n USDbC: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',\n },\n}\n\nexport const ERC20_ABI = [\n {\n inputs: [{ name: 'account', type: 'address' }],\n name: 'balanceOf',\n outputs: [{ name: '', type: 'uint256' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [\n { name: 'spender', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'approve',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [\n { name: 'to', type: 'address' },\n { name: 'amount', type: 'uint256' },\n ],\n name: 'transfer',\n outputs: [{ name: '', type: 'bool' }],\n stateMutability: 'nonpayable',\n type: 'function',\n },\n {\n inputs: [],\n name: 'decimals',\n outputs: [{ name: '', type: 'uint8' }],\n stateMutability: 'view',\n type: 'function',\n },\n {\n inputs: [],\n name: 'symbol',\n outputs: [{ name: '', type: 'string' }],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n","import { http } from 'viem'\nimport type { Address, Hash, Hex } from 'viem'\nimport { privateKeyToAccount } from 'viem/accounts'\nimport { entryPoint06Address } from 'viem/account-abstraction'\nimport { createSmartAccountClient } from 'permissionless'\nimport { toTrustSmartAccount } from 'permissionless/accounts'\n\nimport type {\n AgentConfig,\n BarzAgent,\n TransactionRequest,\n TransactionReceipt,\n AgentPermissions,\n} from './types'\nimport { createClients } from './client'\nimport { PermissionManager } from '../permissions/permissions'\nimport { BarzKitError, ConfigError, FrozenError, humanizeError, TransactionError } from '../utils/errors'\nimport { ERC20_ABI } from '../utils/constants'\n\n/**\n * Create a Barz agent wallet.\n *\n * @example\n * ```ts\n * const agent = await createBarzAgent({\n * chain: 'sepolia',\n * owner: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n * pimlico: { apiKey: 'pim_...' },\n * })\n *\n * console.log('Agent address:', agent.address)\n * ```\n */\nexport async function createBarzAgent(config: AgentConfig): Promise<BarzAgent> {\n validateConfig(config)\n\n const { publicClient, pimlicoClient, chainConfig, bundlerUrl } = createClients(config)\n const ownerAccount = privateKeyToAccount(config.owner)\n\n const smartAccount = await toTrustSmartAccount({\n client: publicClient,\n owner: ownerAccount,\n index: config.index ?? 0n,\n entryPoint: {\n address: entryPoint06Address,\n version: '0.6',\n },\n })\n\n const gasless = config.gasless !== false\n\n const smartAccountClient = createSmartAccountClient({\n account: smartAccount,\n chain: chainConfig.chain,\n bundlerTransport: http(bundlerUrl),\n ...(gasless\n ? {\n paymaster: pimlicoClient,\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }\n : {\n userOperation: {\n estimateFeesPerGas: async () =>\n (await pimlicoClient.getUserOperationGasPrice()).fast,\n },\n }),\n })\n\n if (config.chain === 'base') {\n console.warn('\\u26a0\\ufe0f Using Base mainnet \\u2014 real funds at risk')\n }\n\n const permissionManager = new PermissionManager(config.permissions)\n let frozen = false\n\n const agent: BarzAgent = {\n address: smartAccount.address,\n chain: config.chain,\n owner: ownerAccount.address,\n\n async sendTransaction(tx: TransactionRequest): Promise<Hash> {\n if (frozen) throw new FrozenError()\n permissionManager.validate(tx)\n\n try {\n const hash = await smartAccountClient.sendTransaction({\n to: tx.to,\n value: tx.value ?? 0n,\n data: tx.data ?? '0x',\n })\n\n if (tx.value) permissionManager.recordSpend(tx.value)\n return hash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async batchTransactions(txs: TransactionRequest[]): Promise<Hash> {\n if (frozen) throw new FrozenError()\n if (txs.length === 0) {\n throw new BarzKitError(\n 'batchTransactions requires at least one transaction.',\n 'BATCH_EMPTY',\n )\n }\n\n for (const tx of txs) {\n permissionManager.validate(tx)\n }\n\n try {\n const userOpHash = await smartAccountClient.sendUserOperation({\n calls: txs.map((tx) => ({\n to: tx.to,\n value: tx.value ?? 0n,\n data: tx.data ?? ('0x' as Hex),\n })),\n })\n\n const receipt = await smartAccountClient.waitForUserOperationReceipt({\n hash: userOpHash,\n })\n\n const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n)\n if (totalValue > 0n) permissionManager.recordSpend(totalValue)\n\n return receipt.receipt.transactionHash\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async getBalance(token?: Address): Promise<bigint> {\n try {\n if (!token) {\n return await publicClient.getBalance({ address: smartAccount.address })\n }\n\n const balance = await publicClient.readContract({\n address: token,\n abi: ERC20_ABI,\n functionName: 'balanceOf',\n args: [smartAccount.address],\n })\n\n return balance as bigint\n } catch (error) {\n throw humanizeError(error)\n }\n },\n\n async waitForTransaction(hash: Hash): Promise<TransactionReceipt> {\n try {\n const receipt = await publicClient.waitForTransactionReceipt({ hash })\n return {\n transactionHash: receipt.transactionHash,\n blockNumber: receipt.blockNumber,\n status: receipt.status,\n gasUsed: receipt.gasUsed,\n }\n } catch (error) {\n throw new TransactionError(\n `Failed waiting for transaction ${hash}: ${error instanceof Error ? error.message : error}`,\n hash,\n )\n }\n },\n\n getExplorerUrl(hash: Hash): string {\n return `${chainConfig.explorerUrl}/tx/${hash}`\n },\n\n getPermissions(): AgentPermissions {\n return permissionManager.permissions\n },\n\n updatePermissions(permissions: Partial<AgentPermissions>): void {\n permissionManager.update(permissions)\n },\n\n async freeze(): Promise<Hash> {\n frozen = true\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async unfreeze(): Promise<Hash> {\n frozen = false\n return '0x0000000000000000000000000000000000000000000000000000000000000000' as Hash\n },\n\n async isActive(): Promise<boolean> {\n return !frozen\n },\n }\n\n return agent\n}\n\nfunction validateConfig(config: AgentConfig): void {\n if (!config) throw new ConfigError('Agent config is required.')\n\n if (!config.chain) {\n throw new ConfigError('Missing \"chain\". Supported: sepolia, base-sepolia, base.')\n }\n if (!config.owner) {\n throw new ConfigError('Missing \"owner\". Provide a hex private key.')\n }\n if (!config.owner.startsWith('0x') || config.owner.length !== 66) {\n throw new ConfigError(\n 'Invalid \"owner\" private key. Must be a 32-byte hex string starting with \"0x\" (66 chars total).',\n )\n }\n if (!config.pimlico?.apiKey) {\n throw new ConfigError('Missing \"pimlico.apiKey\". Get a free key at https://dashboard.pimlico.io')\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barzkit/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Self-custody
|
|
5
|
+
"description": "Self-custody AI agent wallets with passkeys, gasless transactions & programmable permissions (ERC-4337)",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist",
|
|
18
|
-
"README.md"
|
|
18
|
+
"README.md",
|
|
19
|
+
"CHANGELOG.md"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
22
|
"build": "tsup",
|
|
@@ -26,17 +27,16 @@
|
|
|
26
27
|
"clean": "rm -rf dist"
|
|
27
28
|
},
|
|
28
29
|
"keywords": [
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
30
|
+
"typescript",
|
|
31
|
+
"sdk",
|
|
32
|
+
"web3",
|
|
33
|
+
"ai-agents",
|
|
34
|
+
"defi",
|
|
33
35
|
"trust-wallet",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"smart-
|
|
37
|
-
"
|
|
38
|
-
"passkeys",
|
|
39
|
-
"gasless"
|
|
36
|
+
"account-abstraction",
|
|
37
|
+
"erc-4337",
|
|
38
|
+
"smart-accounts",
|
|
39
|
+
"barz"
|
|
40
40
|
],
|
|
41
41
|
"author": "",
|
|
42
42
|
"license": "MIT",
|