@barzkit/sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +176 -0
- package/dist/index.cjs +473 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +185 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +461 -0
- package/dist/index.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +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,4CAAA;AAAA,IACnB,iBAAA,EAAmB;AAAA,GACrB;AAAA,EACA,cAAA,EAAgB;AAAA,IACd,KAAA,EAAOC,kBAAA;AAAA,IACP,MAAA,EAAQ,0BAAA;AAAA,IACR,UAAA,EAAY,4CAAA;AAAA,IACZ,YAAA,EAAc,4CAAA;AAAA,IACd,iBAAA,EAAmB,4CAAA;AAAA,IACnB,iBAAA,EAAmB;AAAA,GACrB;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,KAAA,EAAOC,WAAA;AAAA,IACP,MAAA,EAAQ,0BAAA;AAAA,IACR,UAAA,EAAY,oCAAA;AAAA,IACZ,YAAA,EAAc,oCAAA;AAAA,IACd,iBAAA,EAAmB,4CAAA;AAAA,IACnB,iBAAA,EAAmB;AAAA;AAEvB;AAEO,SAAS,eAAe,KAAA,EAAoC;AAC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AA,GAAmC;AACjC,MAAA,OAAO,iBAAA,CAAkB,WAAA;AAAA,IAC3B,CAAA;AAAA,IAEA,kBAAkB,WAAA,EAA8C;AAC9D,MAAA,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 },\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"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Hex, Address, Hash, Chain } from 'viem';
|
|
2
|
+
|
|
3
|
+
type SupportedChain = 'sepolia' | 'base-sepolia' | 'base';
|
|
4
|
+
interface AgentConfig {
|
|
5
|
+
/** Target blockchain network */
|
|
6
|
+
chain: SupportedChain;
|
|
7
|
+
/** Owner's private key (hex). Agent key is derived separately. */
|
|
8
|
+
owner: Hex;
|
|
9
|
+
/** Pimlico configuration for bundler and paymaster */
|
|
10
|
+
pimlico: {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
};
|
|
13
|
+
/** Optional permissions to restrict agent capabilities */
|
|
14
|
+
permissions?: AgentPermissions;
|
|
15
|
+
/** Enable gasless transactions via paymaster. Default: true */
|
|
16
|
+
gasless?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Account index for deterministic address derivation.
|
|
19
|
+
* Use different indices to create multiple wallets from the same owner.
|
|
20
|
+
* Default: 0
|
|
21
|
+
*/
|
|
22
|
+
index?: bigint;
|
|
23
|
+
/** Custom RPC URL. If not provided, uses default public RPC for the chain. */
|
|
24
|
+
rpcUrl?: string;
|
|
25
|
+
}
|
|
26
|
+
interface AgentPermissions {
|
|
27
|
+
/** Maximum amount per single transaction (e.g., '100 USDC') */
|
|
28
|
+
maxAmountPerTx?: string;
|
|
29
|
+
/** Maximum total spend per 24h rolling window (e.g., '500 USDC') */
|
|
30
|
+
maxDailySpend?: string;
|
|
31
|
+
/** Whitelist of token addresses the agent can interact with */
|
|
32
|
+
allowedTokens?: Address[];
|
|
33
|
+
/** Whitelist of contract addresses the agent can call */
|
|
34
|
+
allowedContracts?: Address[];
|
|
35
|
+
/** Time window when agent is allowed to operate (UTC) */
|
|
36
|
+
timeWindow?: {
|
|
37
|
+
start: string;
|
|
38
|
+
end: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
interface TransactionRequest {
|
|
42
|
+
/** Target address */
|
|
43
|
+
to: Address;
|
|
44
|
+
/** ETH value to send (in wei). Default: 0n */
|
|
45
|
+
value?: bigint;
|
|
46
|
+
/** Calldata for contract interaction */
|
|
47
|
+
data?: Hex;
|
|
48
|
+
}
|
|
49
|
+
interface BarzAgent {
|
|
50
|
+
/** The smart account address on-chain */
|
|
51
|
+
readonly address: Address;
|
|
52
|
+
/** The chain this agent operates on */
|
|
53
|
+
readonly chain: SupportedChain;
|
|
54
|
+
/** The owner address (human controller) */
|
|
55
|
+
readonly owner: Address;
|
|
56
|
+
sendTransaction(tx: TransactionRequest): Promise<Hash>;
|
|
57
|
+
batchTransactions(txs: TransactionRequest[]): Promise<Hash>;
|
|
58
|
+
getBalance(token?: Address): Promise<bigint>;
|
|
59
|
+
waitForTransaction(hash: Hash): Promise<TransactionReceipt>;
|
|
60
|
+
getPermissions(): AgentPermissions;
|
|
61
|
+
updatePermissions(permissions: Partial<AgentPermissions>): void;
|
|
62
|
+
freeze(): Promise<Hash>;
|
|
63
|
+
unfreeze(): Promise<Hash>;
|
|
64
|
+
isActive(): Promise<boolean>;
|
|
65
|
+
}
|
|
66
|
+
interface ChainConfig {
|
|
67
|
+
chain: Chain;
|
|
68
|
+
rpcUrl: string;
|
|
69
|
+
bundlerUrl: string;
|
|
70
|
+
paymasterUrl: string;
|
|
71
|
+
entryPointAddress: Address;
|
|
72
|
+
entryPointVersion: '0.6';
|
|
73
|
+
}
|
|
74
|
+
interface TransactionReceipt {
|
|
75
|
+
transactionHash: Hash;
|
|
76
|
+
blockNumber: bigint;
|
|
77
|
+
status: 'success' | 'reverted';
|
|
78
|
+
gasUsed: bigint;
|
|
79
|
+
}
|
|
80
|
+
type AgentEvent = 'transaction:sent' | 'transaction:confirmed' | 'transaction:failed' | 'permissions:updated' | 'agent:frozen' | 'agent:unfrozen';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create a Barz agent wallet.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const agent = await createBarzAgent({
|
|
88
|
+
* chain: 'sepolia',
|
|
89
|
+
* owner: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
90
|
+
* pimlico: { apiKey: 'pim_...' },
|
|
91
|
+
* })
|
|
92
|
+
*
|
|
93
|
+
* console.log('Agent address:', agent.address)
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function createBarzAgent(config: AgentConfig): Promise<BarzAgent>;
|
|
97
|
+
|
|
98
|
+
declare class BarzKitError extends Error {
|
|
99
|
+
readonly code: string;
|
|
100
|
+
constructor(message: string, code: string);
|
|
101
|
+
}
|
|
102
|
+
declare class ConfigError extends BarzKitError {
|
|
103
|
+
constructor(message: string);
|
|
104
|
+
}
|
|
105
|
+
declare class PermissionError extends BarzKitError {
|
|
106
|
+
constructor(message: string);
|
|
107
|
+
}
|
|
108
|
+
declare class FrozenError extends BarzKitError {
|
|
109
|
+
constructor();
|
|
110
|
+
}
|
|
111
|
+
declare class TransactionError extends BarzKitError {
|
|
112
|
+
readonly txHash?: string;
|
|
113
|
+
constructor(message: string, txHash?: string);
|
|
114
|
+
}
|
|
115
|
+
declare class BundlerError extends BarzKitError {
|
|
116
|
+
constructor(message: string);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare const CHAIN_CONFIGS: Record<SupportedChain, ChainConfig>;
|
|
120
|
+
declare function getChainConfig(chain: SupportedChain): ChainConfig;
|
|
121
|
+
|
|
122
|
+
declare const TOKENS: Record<string, Record<string, Address>>;
|
|
123
|
+
declare const ERC20_ABI: readonly [{
|
|
124
|
+
readonly inputs: readonly [{
|
|
125
|
+
readonly name: "account";
|
|
126
|
+
readonly type: "address";
|
|
127
|
+
}];
|
|
128
|
+
readonly name: "balanceOf";
|
|
129
|
+
readonly outputs: readonly [{
|
|
130
|
+
readonly name: "";
|
|
131
|
+
readonly type: "uint256";
|
|
132
|
+
}];
|
|
133
|
+
readonly stateMutability: "view";
|
|
134
|
+
readonly type: "function";
|
|
135
|
+
}, {
|
|
136
|
+
readonly inputs: readonly [{
|
|
137
|
+
readonly name: "spender";
|
|
138
|
+
readonly type: "address";
|
|
139
|
+
}, {
|
|
140
|
+
readonly name: "amount";
|
|
141
|
+
readonly type: "uint256";
|
|
142
|
+
}];
|
|
143
|
+
readonly name: "approve";
|
|
144
|
+
readonly outputs: readonly [{
|
|
145
|
+
readonly name: "";
|
|
146
|
+
readonly type: "bool";
|
|
147
|
+
}];
|
|
148
|
+
readonly stateMutability: "nonpayable";
|
|
149
|
+
readonly type: "function";
|
|
150
|
+
}, {
|
|
151
|
+
readonly inputs: readonly [{
|
|
152
|
+
readonly name: "to";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}, {
|
|
155
|
+
readonly name: "amount";
|
|
156
|
+
readonly type: "uint256";
|
|
157
|
+
}];
|
|
158
|
+
readonly name: "transfer";
|
|
159
|
+
readonly outputs: readonly [{
|
|
160
|
+
readonly name: "";
|
|
161
|
+
readonly type: "bool";
|
|
162
|
+
}];
|
|
163
|
+
readonly stateMutability: "nonpayable";
|
|
164
|
+
readonly type: "function";
|
|
165
|
+
}, {
|
|
166
|
+
readonly inputs: readonly [];
|
|
167
|
+
readonly name: "decimals";
|
|
168
|
+
readonly outputs: readonly [{
|
|
169
|
+
readonly name: "";
|
|
170
|
+
readonly type: "uint8";
|
|
171
|
+
}];
|
|
172
|
+
readonly stateMutability: "view";
|
|
173
|
+
readonly type: "function";
|
|
174
|
+
}, {
|
|
175
|
+
readonly inputs: readonly [];
|
|
176
|
+
readonly name: "symbol";
|
|
177
|
+
readonly outputs: readonly [{
|
|
178
|
+
readonly name: "";
|
|
179
|
+
readonly type: "string";
|
|
180
|
+
}];
|
|
181
|
+
readonly stateMutability: "view";
|
|
182
|
+
readonly type: "function";
|
|
183
|
+
}];
|
|
184
|
+
|
|
185
|
+
export { type AgentConfig, type AgentEvent, type AgentPermissions, type BarzAgent, BarzKitError, BundlerError, CHAIN_CONFIGS, type ChainConfig, ConfigError, ERC20_ABI, FrozenError, PermissionError, type SupportedChain, TOKENS, TransactionError, type TransactionReceipt, type TransactionRequest, createBarzAgent, getChainConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { Hex, Address, Hash, Chain } from 'viem';
|
|
2
|
+
|
|
3
|
+
type SupportedChain = 'sepolia' | 'base-sepolia' | 'base';
|
|
4
|
+
interface AgentConfig {
|
|
5
|
+
/** Target blockchain network */
|
|
6
|
+
chain: SupportedChain;
|
|
7
|
+
/** Owner's private key (hex). Agent key is derived separately. */
|
|
8
|
+
owner: Hex;
|
|
9
|
+
/** Pimlico configuration for bundler and paymaster */
|
|
10
|
+
pimlico: {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
};
|
|
13
|
+
/** Optional permissions to restrict agent capabilities */
|
|
14
|
+
permissions?: AgentPermissions;
|
|
15
|
+
/** Enable gasless transactions via paymaster. Default: true */
|
|
16
|
+
gasless?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Account index for deterministic address derivation.
|
|
19
|
+
* Use different indices to create multiple wallets from the same owner.
|
|
20
|
+
* Default: 0
|
|
21
|
+
*/
|
|
22
|
+
index?: bigint;
|
|
23
|
+
/** Custom RPC URL. If not provided, uses default public RPC for the chain. */
|
|
24
|
+
rpcUrl?: string;
|
|
25
|
+
}
|
|
26
|
+
interface AgentPermissions {
|
|
27
|
+
/** Maximum amount per single transaction (e.g., '100 USDC') */
|
|
28
|
+
maxAmountPerTx?: string;
|
|
29
|
+
/** Maximum total spend per 24h rolling window (e.g., '500 USDC') */
|
|
30
|
+
maxDailySpend?: string;
|
|
31
|
+
/** Whitelist of token addresses the agent can interact with */
|
|
32
|
+
allowedTokens?: Address[];
|
|
33
|
+
/** Whitelist of contract addresses the agent can call */
|
|
34
|
+
allowedContracts?: Address[];
|
|
35
|
+
/** Time window when agent is allowed to operate (UTC) */
|
|
36
|
+
timeWindow?: {
|
|
37
|
+
start: string;
|
|
38
|
+
end: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
interface TransactionRequest {
|
|
42
|
+
/** Target address */
|
|
43
|
+
to: Address;
|
|
44
|
+
/** ETH value to send (in wei). Default: 0n */
|
|
45
|
+
value?: bigint;
|
|
46
|
+
/** Calldata for contract interaction */
|
|
47
|
+
data?: Hex;
|
|
48
|
+
}
|
|
49
|
+
interface BarzAgent {
|
|
50
|
+
/** The smart account address on-chain */
|
|
51
|
+
readonly address: Address;
|
|
52
|
+
/** The chain this agent operates on */
|
|
53
|
+
readonly chain: SupportedChain;
|
|
54
|
+
/** The owner address (human controller) */
|
|
55
|
+
readonly owner: Address;
|
|
56
|
+
sendTransaction(tx: TransactionRequest): Promise<Hash>;
|
|
57
|
+
batchTransactions(txs: TransactionRequest[]): Promise<Hash>;
|
|
58
|
+
getBalance(token?: Address): Promise<bigint>;
|
|
59
|
+
waitForTransaction(hash: Hash): Promise<TransactionReceipt>;
|
|
60
|
+
getPermissions(): AgentPermissions;
|
|
61
|
+
updatePermissions(permissions: Partial<AgentPermissions>): void;
|
|
62
|
+
freeze(): Promise<Hash>;
|
|
63
|
+
unfreeze(): Promise<Hash>;
|
|
64
|
+
isActive(): Promise<boolean>;
|
|
65
|
+
}
|
|
66
|
+
interface ChainConfig {
|
|
67
|
+
chain: Chain;
|
|
68
|
+
rpcUrl: string;
|
|
69
|
+
bundlerUrl: string;
|
|
70
|
+
paymasterUrl: string;
|
|
71
|
+
entryPointAddress: Address;
|
|
72
|
+
entryPointVersion: '0.6';
|
|
73
|
+
}
|
|
74
|
+
interface TransactionReceipt {
|
|
75
|
+
transactionHash: Hash;
|
|
76
|
+
blockNumber: bigint;
|
|
77
|
+
status: 'success' | 'reverted';
|
|
78
|
+
gasUsed: bigint;
|
|
79
|
+
}
|
|
80
|
+
type AgentEvent = 'transaction:sent' | 'transaction:confirmed' | 'transaction:failed' | 'permissions:updated' | 'agent:frozen' | 'agent:unfrozen';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Create a Barz agent wallet.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const agent = await createBarzAgent({
|
|
88
|
+
* chain: 'sepolia',
|
|
89
|
+
* owner: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
90
|
+
* pimlico: { apiKey: 'pim_...' },
|
|
91
|
+
* })
|
|
92
|
+
*
|
|
93
|
+
* console.log('Agent address:', agent.address)
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function createBarzAgent(config: AgentConfig): Promise<BarzAgent>;
|
|
97
|
+
|
|
98
|
+
declare class BarzKitError extends Error {
|
|
99
|
+
readonly code: string;
|
|
100
|
+
constructor(message: string, code: string);
|
|
101
|
+
}
|
|
102
|
+
declare class ConfigError extends BarzKitError {
|
|
103
|
+
constructor(message: string);
|
|
104
|
+
}
|
|
105
|
+
declare class PermissionError extends BarzKitError {
|
|
106
|
+
constructor(message: string);
|
|
107
|
+
}
|
|
108
|
+
declare class FrozenError extends BarzKitError {
|
|
109
|
+
constructor();
|
|
110
|
+
}
|
|
111
|
+
declare class TransactionError extends BarzKitError {
|
|
112
|
+
readonly txHash?: string;
|
|
113
|
+
constructor(message: string, txHash?: string);
|
|
114
|
+
}
|
|
115
|
+
declare class BundlerError extends BarzKitError {
|
|
116
|
+
constructor(message: string);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare const CHAIN_CONFIGS: Record<SupportedChain, ChainConfig>;
|
|
120
|
+
declare function getChainConfig(chain: SupportedChain): ChainConfig;
|
|
121
|
+
|
|
122
|
+
declare const TOKENS: Record<string, Record<string, Address>>;
|
|
123
|
+
declare const ERC20_ABI: readonly [{
|
|
124
|
+
readonly inputs: readonly [{
|
|
125
|
+
readonly name: "account";
|
|
126
|
+
readonly type: "address";
|
|
127
|
+
}];
|
|
128
|
+
readonly name: "balanceOf";
|
|
129
|
+
readonly outputs: readonly [{
|
|
130
|
+
readonly name: "";
|
|
131
|
+
readonly type: "uint256";
|
|
132
|
+
}];
|
|
133
|
+
readonly stateMutability: "view";
|
|
134
|
+
readonly type: "function";
|
|
135
|
+
}, {
|
|
136
|
+
readonly inputs: readonly [{
|
|
137
|
+
readonly name: "spender";
|
|
138
|
+
readonly type: "address";
|
|
139
|
+
}, {
|
|
140
|
+
readonly name: "amount";
|
|
141
|
+
readonly type: "uint256";
|
|
142
|
+
}];
|
|
143
|
+
readonly name: "approve";
|
|
144
|
+
readonly outputs: readonly [{
|
|
145
|
+
readonly name: "";
|
|
146
|
+
readonly type: "bool";
|
|
147
|
+
}];
|
|
148
|
+
readonly stateMutability: "nonpayable";
|
|
149
|
+
readonly type: "function";
|
|
150
|
+
}, {
|
|
151
|
+
readonly inputs: readonly [{
|
|
152
|
+
readonly name: "to";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
}, {
|
|
155
|
+
readonly name: "amount";
|
|
156
|
+
readonly type: "uint256";
|
|
157
|
+
}];
|
|
158
|
+
readonly name: "transfer";
|
|
159
|
+
readonly outputs: readonly [{
|
|
160
|
+
readonly name: "";
|
|
161
|
+
readonly type: "bool";
|
|
162
|
+
}];
|
|
163
|
+
readonly stateMutability: "nonpayable";
|
|
164
|
+
readonly type: "function";
|
|
165
|
+
}, {
|
|
166
|
+
readonly inputs: readonly [];
|
|
167
|
+
readonly name: "decimals";
|
|
168
|
+
readonly outputs: readonly [{
|
|
169
|
+
readonly name: "";
|
|
170
|
+
readonly type: "uint8";
|
|
171
|
+
}];
|
|
172
|
+
readonly stateMutability: "view";
|
|
173
|
+
readonly type: "function";
|
|
174
|
+
}, {
|
|
175
|
+
readonly inputs: readonly [];
|
|
176
|
+
readonly name: "symbol";
|
|
177
|
+
readonly outputs: readonly [{
|
|
178
|
+
readonly name: "";
|
|
179
|
+
readonly type: "string";
|
|
180
|
+
}];
|
|
181
|
+
readonly stateMutability: "view";
|
|
182
|
+
readonly type: "function";
|
|
183
|
+
}];
|
|
184
|
+
|
|
185
|
+
export { type AgentConfig, type AgentEvent, type AgentPermissions, type BarzAgent, BarzKitError, BundlerError, CHAIN_CONFIGS, type ChainConfig, ConfigError, ERC20_ABI, FrozenError, PermissionError, type SupportedChain, TOKENS, TransactionError, type TransactionReceipt, type TransactionRequest, createBarzAgent, getChainConfig };
|