@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
package/dist/index.js
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { http, createPublicClient } from 'viem';
|
|
2
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
3
|
+
import { entryPoint06Address } from 'viem/account-abstraction';
|
|
4
|
+
import { createSmartAccountClient } from 'permissionless';
|
|
5
|
+
import { toTrustSmartAccount } from 'permissionless/accounts';
|
|
6
|
+
import { createPimlicoClient } from 'permissionless/clients/pimlico';
|
|
7
|
+
import { base, baseSepolia, sepolia } from 'viem/chains';
|
|
8
|
+
|
|
9
|
+
// src/core/account.ts
|
|
10
|
+
var CHAIN_CONFIGS = {
|
|
11
|
+
sepolia: {
|
|
12
|
+
chain: sepolia,
|
|
13
|
+
rpcUrl: "https://ethereum-sepolia-rpc.publicnode.com",
|
|
14
|
+
bundlerUrl: "https://api.pimlico.io/v2/sepolia/rpc",
|
|
15
|
+
paymasterUrl: "https://api.pimlico.io/v2/sepolia/rpc",
|
|
16
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
17
|
+
entryPointVersion: "0.6"
|
|
18
|
+
},
|
|
19
|
+
"base-sepolia": {
|
|
20
|
+
chain: baseSepolia,
|
|
21
|
+
rpcUrl: "https://sepolia.base.org",
|
|
22
|
+
bundlerUrl: "https://api.pimlico.io/v2/base-sepolia/rpc",
|
|
23
|
+
paymasterUrl: "https://api.pimlico.io/v2/base-sepolia/rpc",
|
|
24
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
25
|
+
entryPointVersion: "0.6"
|
|
26
|
+
},
|
|
27
|
+
base: {
|
|
28
|
+
chain: base,
|
|
29
|
+
rpcUrl: "https://mainnet.base.org",
|
|
30
|
+
bundlerUrl: "https://api.pimlico.io/v2/base/rpc",
|
|
31
|
+
paymasterUrl: "https://api.pimlico.io/v2/base/rpc",
|
|
32
|
+
entryPointAddress: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
33
|
+
entryPointVersion: "0.6"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function getChainConfig(chain) {
|
|
37
|
+
const config = CHAIN_CONFIGS[chain];
|
|
38
|
+
if (!config) {
|
|
39
|
+
const supported = Object.keys(CHAIN_CONFIGS).join(", ");
|
|
40
|
+
throw new Error(`Unsupported chain: "${chain}". Supported: ${supported}`);
|
|
41
|
+
}
|
|
42
|
+
return config;
|
|
43
|
+
}
|
|
44
|
+
function buildBundlerUrl(chainConfig, apiKey) {
|
|
45
|
+
return `${chainConfig.bundlerUrl}?apikey=${apiKey}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/utils/errors.ts
|
|
49
|
+
var BarzKitError = class extends Error {
|
|
50
|
+
code;
|
|
51
|
+
constructor(message, code) {
|
|
52
|
+
super(message);
|
|
53
|
+
this.name = "BarzKitError";
|
|
54
|
+
this.code = code;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var ConfigError = class extends BarzKitError {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message, "CONFIG_ERROR");
|
|
60
|
+
this.name = "ConfigError";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var PermissionError = class extends BarzKitError {
|
|
64
|
+
constructor(message) {
|
|
65
|
+
super(message, "PERMISSION_DENIED");
|
|
66
|
+
this.name = "PermissionError";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var FrozenError = class extends BarzKitError {
|
|
70
|
+
constructor() {
|
|
71
|
+
super(
|
|
72
|
+
"Agent wallet is frozen. Call agent.unfreeze() to resume operation.",
|
|
73
|
+
"AGENT_FROZEN"
|
|
74
|
+
);
|
|
75
|
+
this.name = "FrozenError";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var TransactionError = class extends BarzKitError {
|
|
79
|
+
txHash;
|
|
80
|
+
constructor(message, txHash) {
|
|
81
|
+
super(message, "TRANSACTION_FAILED");
|
|
82
|
+
this.name = "TransactionError";
|
|
83
|
+
this.txHash = txHash;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var BundlerError = class extends BarzKitError {
|
|
87
|
+
constructor(message) {
|
|
88
|
+
super(message, "BUNDLER_ERROR");
|
|
89
|
+
this.name = "BundlerError";
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
function humanizeError(error) {
|
|
93
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
94
|
+
if (message.includes("AA21")) {
|
|
95
|
+
return new TransactionError(
|
|
96
|
+
"Smart account has insufficient funds to pay for gas. Send ETH to the agent wallet address, or enable gasless mode."
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
if (message.includes("AA25")) {
|
|
100
|
+
return new TransactionError(
|
|
101
|
+
"Invalid signature. The agent key may not be authorized for this account."
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (message.includes("AA31")) {
|
|
105
|
+
return new TransactionError(
|
|
106
|
+
"Paymaster deposit too low. The paymaster may be out of funds. Try again later or switch to self-funded mode."
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
if (message.includes("AA33")) {
|
|
110
|
+
return new TransactionError(
|
|
111
|
+
"Transaction reverted during validation. The calldata may be invalid or the target contract may have rejected the call."
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
if (message.includes("AA40") || message.includes("AA41")) {
|
|
115
|
+
return new TransactionError(
|
|
116
|
+
"Paymaster validation failed. The paymaster may not support this operation."
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
if (message.includes("insufficient funds")) {
|
|
120
|
+
return new TransactionError(
|
|
121
|
+
"Insufficient funds in the agent wallet. Check balance with agent.getBalance()."
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return new BarzKitError(`Transaction failed: ${message}`, "UNKNOWN_ERROR");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// src/core/client.ts
|
|
128
|
+
function createClients(config) {
|
|
129
|
+
if (!config.chain) {
|
|
130
|
+
throw new ConfigError('Missing required field: "chain". Example: { chain: "sepolia" }');
|
|
131
|
+
}
|
|
132
|
+
if (!config.owner) {
|
|
133
|
+
throw new ConfigError('Missing required field: "owner". Provide a hex private key.');
|
|
134
|
+
}
|
|
135
|
+
if (!config.pimlico?.apiKey) {
|
|
136
|
+
throw new ConfigError(
|
|
137
|
+
'Missing required field: "pimlico.apiKey". Get a free API key at https://dashboard.pimlico.io'
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const chainConfig = getChainConfig(config.chain);
|
|
141
|
+
const rpcUrl = config.rpcUrl || chainConfig.rpcUrl;
|
|
142
|
+
const bundlerUrl = buildBundlerUrl(chainConfig, config.pimlico.apiKey);
|
|
143
|
+
const publicClient = createPublicClient({
|
|
144
|
+
chain: chainConfig.chain,
|
|
145
|
+
transport: http(rpcUrl)
|
|
146
|
+
});
|
|
147
|
+
const pimlicoClient = createPimlicoClient({
|
|
148
|
+
transport: http(bundlerUrl),
|
|
149
|
+
entryPoint: {
|
|
150
|
+
address: entryPoint06Address,
|
|
151
|
+
version: "0.6"
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return {
|
|
155
|
+
publicClient,
|
|
156
|
+
pimlicoClient,
|
|
157
|
+
chainConfig,
|
|
158
|
+
bundlerUrl
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// src/permissions/permissions.ts
|
|
163
|
+
var PermissionManager = class {
|
|
164
|
+
_permissions;
|
|
165
|
+
_dailySpent = 0n;
|
|
166
|
+
_dailyResetTime = Date.now();
|
|
167
|
+
constructor(permissions = {}) {
|
|
168
|
+
this._permissions = { ...permissions };
|
|
169
|
+
}
|
|
170
|
+
get permissions() {
|
|
171
|
+
return { ...this._permissions };
|
|
172
|
+
}
|
|
173
|
+
update(permissions) {
|
|
174
|
+
this._permissions = { ...this._permissions, ...permissions };
|
|
175
|
+
}
|
|
176
|
+
validate(tx) {
|
|
177
|
+
const p = this._permissions;
|
|
178
|
+
if (p.allowedContracts && p.allowedContracts.length > 0) {
|
|
179
|
+
const target = tx.to.toLowerCase();
|
|
180
|
+
const allowed = p.allowedContracts.map((a) => a.toLowerCase());
|
|
181
|
+
if (!allowed.includes(target)) {
|
|
182
|
+
throw new PermissionError(
|
|
183
|
+
`Target contract ${tx.to} is not in the allowed list. Allowed: ${p.allowedContracts.join(", ")}`
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
if (p.timeWindow) {
|
|
188
|
+
const now = /* @__PURE__ */ new Date();
|
|
189
|
+
const hours = now.getUTCHours();
|
|
190
|
+
const minutes = now.getUTCMinutes();
|
|
191
|
+
const currentTime = hours * 60 + minutes;
|
|
192
|
+
const [startH, startM] = p.timeWindow.start.split(":").map(Number);
|
|
193
|
+
const [endH, endM] = p.timeWindow.end.split(":").map(Number);
|
|
194
|
+
const startTime = startH * 60 + startM;
|
|
195
|
+
const endTime = endH * 60 + endM;
|
|
196
|
+
if (currentTime < startTime || currentTime > endTime) {
|
|
197
|
+
throw new PermissionError(
|
|
198
|
+
`Transaction outside allowed time window. Allowed: ${p.timeWindow.start} - ${p.timeWindow.end} UTC. Current: ${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")} UTC.`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (p.maxAmountPerTx && tx.value) {
|
|
203
|
+
const limit = parseHumanAmount(p.maxAmountPerTx);
|
|
204
|
+
if (limit !== null && tx.value > limit) {
|
|
205
|
+
throw new PermissionError(
|
|
206
|
+
`Transaction value ${tx.value} exceeds per-transaction limit of ${p.maxAmountPerTx}.`
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (p.maxDailySpend && tx.value) {
|
|
211
|
+
this._resetDailyIfNeeded();
|
|
212
|
+
const limit = parseHumanAmount(p.maxDailySpend);
|
|
213
|
+
if (limit !== null && this._dailySpent + tx.value > limit) {
|
|
214
|
+
throw new PermissionError(
|
|
215
|
+
`Transaction would exceed daily spend limit of ${p.maxDailySpend}. Already spent today: ${this._dailySpent}. Requested: ${tx.value}.`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
recordSpend(value) {
|
|
221
|
+
this._resetDailyIfNeeded();
|
|
222
|
+
this._dailySpent += value;
|
|
223
|
+
}
|
|
224
|
+
_resetDailyIfNeeded() {
|
|
225
|
+
const now = Date.now();
|
|
226
|
+
const ONE_DAY = 24 * 60 * 60 * 1e3;
|
|
227
|
+
if (now - this._dailyResetTime > ONE_DAY) {
|
|
228
|
+
this._dailySpent = 0n;
|
|
229
|
+
this._dailyResetTime = now;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
function parseHumanAmount(amount) {
|
|
234
|
+
const parts = amount.trim().split(/\s+/);
|
|
235
|
+
const num = parseFloat(parts[0]);
|
|
236
|
+
if (isNaN(num)) return null;
|
|
237
|
+
const unit = parts[1]?.toUpperCase() || "WEI";
|
|
238
|
+
switch (unit) {
|
|
239
|
+
case "ETH":
|
|
240
|
+
return BigInt(Math.floor(num * 1e18));
|
|
241
|
+
case "GWEI":
|
|
242
|
+
return BigInt(Math.floor(num * 1e9));
|
|
243
|
+
case "WEI":
|
|
244
|
+
return BigInt(Math.floor(num));
|
|
245
|
+
case "USDC":
|
|
246
|
+
case "USDT":
|
|
247
|
+
return BigInt(Math.floor(num * 1e6));
|
|
248
|
+
case "DAI":
|
|
249
|
+
return BigInt(Math.floor(num * 1e18));
|
|
250
|
+
default:
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// src/utils/constants.ts
|
|
256
|
+
var TOKENS = {
|
|
257
|
+
sepolia: {
|
|
258
|
+
USDC: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
|
|
259
|
+
WETH: "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
|
|
260
|
+
DAI: "0x68194a729C2450ad26072b3D33ADaCbcef39D574"
|
|
261
|
+
},
|
|
262
|
+
"base-sepolia": {
|
|
263
|
+
USDC: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
264
|
+
WETH: "0x4200000000000000000000000000000000000006"
|
|
265
|
+
},
|
|
266
|
+
base: {
|
|
267
|
+
USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
268
|
+
WETH: "0x4200000000000000000000000000000000000006",
|
|
269
|
+
DAI: "0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",
|
|
270
|
+
USDbC: "0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA"
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var ERC20_ABI = [
|
|
274
|
+
{
|
|
275
|
+
inputs: [{ name: "account", type: "address" }],
|
|
276
|
+
name: "balanceOf",
|
|
277
|
+
outputs: [{ name: "", type: "uint256" }],
|
|
278
|
+
stateMutability: "view",
|
|
279
|
+
type: "function"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
inputs: [
|
|
283
|
+
{ name: "spender", type: "address" },
|
|
284
|
+
{ name: "amount", type: "uint256" }
|
|
285
|
+
],
|
|
286
|
+
name: "approve",
|
|
287
|
+
outputs: [{ name: "", type: "bool" }],
|
|
288
|
+
stateMutability: "nonpayable",
|
|
289
|
+
type: "function"
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
inputs: [
|
|
293
|
+
{ name: "to", type: "address" },
|
|
294
|
+
{ name: "amount", type: "uint256" }
|
|
295
|
+
],
|
|
296
|
+
name: "transfer",
|
|
297
|
+
outputs: [{ name: "", type: "bool" }],
|
|
298
|
+
stateMutability: "nonpayable",
|
|
299
|
+
type: "function"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
inputs: [],
|
|
303
|
+
name: "decimals",
|
|
304
|
+
outputs: [{ name: "", type: "uint8" }],
|
|
305
|
+
stateMutability: "view",
|
|
306
|
+
type: "function"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
inputs: [],
|
|
310
|
+
name: "symbol",
|
|
311
|
+
outputs: [{ name: "", type: "string" }],
|
|
312
|
+
stateMutability: "view",
|
|
313
|
+
type: "function"
|
|
314
|
+
}
|
|
315
|
+
];
|
|
316
|
+
|
|
317
|
+
// src/core/account.ts
|
|
318
|
+
async function createBarzAgent(config) {
|
|
319
|
+
validateConfig(config);
|
|
320
|
+
const { publicClient, pimlicoClient, chainConfig, bundlerUrl } = createClients(config);
|
|
321
|
+
const ownerAccount = privateKeyToAccount(config.owner);
|
|
322
|
+
const smartAccount = await toTrustSmartAccount({
|
|
323
|
+
client: publicClient,
|
|
324
|
+
owner: ownerAccount,
|
|
325
|
+
index: config.index ?? 0n,
|
|
326
|
+
entryPoint: {
|
|
327
|
+
address: entryPoint06Address,
|
|
328
|
+
version: "0.6"
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const gasless = config.gasless !== false;
|
|
332
|
+
const smartAccountClient = createSmartAccountClient({
|
|
333
|
+
account: smartAccount,
|
|
334
|
+
chain: chainConfig.chain,
|
|
335
|
+
bundlerTransport: http(bundlerUrl),
|
|
336
|
+
...gasless ? {
|
|
337
|
+
paymaster: pimlicoClient,
|
|
338
|
+
userOperation: {
|
|
339
|
+
estimateFeesPerGas: async () => (await pimlicoClient.getUserOperationGasPrice()).fast
|
|
340
|
+
}
|
|
341
|
+
} : {
|
|
342
|
+
userOperation: {
|
|
343
|
+
estimateFeesPerGas: async () => (await pimlicoClient.getUserOperationGasPrice()).fast
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
const permissionManager = new PermissionManager(config.permissions);
|
|
348
|
+
let frozen = false;
|
|
349
|
+
const agent = {
|
|
350
|
+
address: smartAccount.address,
|
|
351
|
+
chain: config.chain,
|
|
352
|
+
owner: ownerAccount.address,
|
|
353
|
+
async sendTransaction(tx) {
|
|
354
|
+
if (frozen) throw new FrozenError();
|
|
355
|
+
permissionManager.validate(tx);
|
|
356
|
+
try {
|
|
357
|
+
const hash = await smartAccountClient.sendTransaction({
|
|
358
|
+
to: tx.to,
|
|
359
|
+
value: tx.value ?? 0n,
|
|
360
|
+
data: tx.data ?? "0x"
|
|
361
|
+
});
|
|
362
|
+
if (tx.value) permissionManager.recordSpend(tx.value);
|
|
363
|
+
return hash;
|
|
364
|
+
} catch (error) {
|
|
365
|
+
throw humanizeError(error);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
async batchTransactions(txs) {
|
|
369
|
+
if (frozen) throw new FrozenError();
|
|
370
|
+
if (txs.length === 0) {
|
|
371
|
+
throw new ConfigError("batchTransactions requires at least one transaction.");
|
|
372
|
+
}
|
|
373
|
+
for (const tx of txs) {
|
|
374
|
+
permissionManager.validate(tx);
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
const hash = await smartAccountClient.sendTransaction({
|
|
378
|
+
to: txs[0].to,
|
|
379
|
+
value: txs[0].value ?? 0n,
|
|
380
|
+
data: txs[0].data ?? "0x"
|
|
381
|
+
});
|
|
382
|
+
const totalValue = txs.reduce((sum, tx) => sum + (tx.value ?? 0n), 0n);
|
|
383
|
+
if (totalValue > 0n) permissionManager.recordSpend(totalValue);
|
|
384
|
+
return hash;
|
|
385
|
+
} catch (error) {
|
|
386
|
+
throw humanizeError(error);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
async getBalance(token) {
|
|
390
|
+
try {
|
|
391
|
+
if (!token) {
|
|
392
|
+
return await publicClient.getBalance({ address: smartAccount.address });
|
|
393
|
+
}
|
|
394
|
+
const balance = await publicClient.readContract({
|
|
395
|
+
address: token,
|
|
396
|
+
abi: ERC20_ABI,
|
|
397
|
+
functionName: "balanceOf",
|
|
398
|
+
args: [smartAccount.address]
|
|
399
|
+
});
|
|
400
|
+
return balance;
|
|
401
|
+
} catch (error) {
|
|
402
|
+
throw humanizeError(error);
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
async waitForTransaction(hash) {
|
|
406
|
+
try {
|
|
407
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
408
|
+
return {
|
|
409
|
+
transactionHash: receipt.transactionHash,
|
|
410
|
+
blockNumber: receipt.blockNumber,
|
|
411
|
+
status: receipt.status,
|
|
412
|
+
gasUsed: receipt.gasUsed
|
|
413
|
+
};
|
|
414
|
+
} catch (error) {
|
|
415
|
+
throw new TransactionError(
|
|
416
|
+
`Failed waiting for transaction ${hash}: ${error instanceof Error ? error.message : error}`,
|
|
417
|
+
hash
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
},
|
|
421
|
+
getPermissions() {
|
|
422
|
+
return permissionManager.permissions;
|
|
423
|
+
},
|
|
424
|
+
updatePermissions(permissions) {
|
|
425
|
+
permissionManager.update(permissions);
|
|
426
|
+
},
|
|
427
|
+
async freeze() {
|
|
428
|
+
frozen = true;
|
|
429
|
+
return "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
430
|
+
},
|
|
431
|
+
async unfreeze() {
|
|
432
|
+
frozen = false;
|
|
433
|
+
return "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
434
|
+
},
|
|
435
|
+
async isActive() {
|
|
436
|
+
return !frozen;
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
return agent;
|
|
440
|
+
}
|
|
441
|
+
function validateConfig(config) {
|
|
442
|
+
if (!config) throw new ConfigError("Agent config is required.");
|
|
443
|
+
if (!config.chain) {
|
|
444
|
+
throw new ConfigError('Missing "chain". Supported: sepolia, base-sepolia, base.');
|
|
445
|
+
}
|
|
446
|
+
if (!config.owner) {
|
|
447
|
+
throw new ConfigError('Missing "owner". Provide a hex private key.');
|
|
448
|
+
}
|
|
449
|
+
if (!config.owner.startsWith("0x") || config.owner.length !== 66) {
|
|
450
|
+
throw new ConfigError(
|
|
451
|
+
'Invalid "owner" private key. Must be a 32-byte hex string starting with "0x" (66 chars total).'
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
if (!config.pimlico?.apiKey) {
|
|
455
|
+
throw new ConfigError('Missing "pimlico.apiKey". Get a free key at https://dashboard.pimlico.io');
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export { BarzKitError, BundlerError, CHAIN_CONFIGS, ConfigError, ERC20_ABI, FrozenError, PermissionError, TOKENS, TransactionError, createBarzAgent, getChainConfig };
|
|
460
|
+
//# sourceMappingURL=index.js.map
|
|
461
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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":["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,EAAmB;AAAA,GACrB;AAAA,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AAO,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"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@barzkit/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Self-custody wallet infrastructure for AI agents. Deploy an autonomous, audited smart account in 5 minutes.",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup",
|
|
22
|
+
"dev": "tsup --watch",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"lint": "tsc --noEmit",
|
|
26
|
+
"clean": "rm -rf dist"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"ai-agent",
|
|
30
|
+
"wallet",
|
|
31
|
+
"erc-4337",
|
|
32
|
+
"account-abstraction",
|
|
33
|
+
"trust-wallet",
|
|
34
|
+
"barz",
|
|
35
|
+
"self-custody",
|
|
36
|
+
"smart-account",
|
|
37
|
+
"diamond-proxy",
|
|
38
|
+
"passkeys",
|
|
39
|
+
"gasless"
|
|
40
|
+
],
|
|
41
|
+
"author": "",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/barzkit/sdk"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/barzkit/sdk#readme",
|
|
48
|
+
"bugs": {
|
|
49
|
+
"url": "https://github.com/barzkit/sdk/issues"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"permissionless": "^0.3.4",
|
|
53
|
+
"viem": "^2.46.3"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^22.13.0",
|
|
57
|
+
"tslib": "^2.8.1",
|
|
58
|
+
"tsup": "^8.5.0",
|
|
59
|
+
"tsx": "^4.21.0",
|
|
60
|
+
"typescript": "^5.9.3",
|
|
61
|
+
"vitest": "^3.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"viem": ">=2.21.0"
|
|
65
|
+
},
|
|
66
|
+
"overrides": {
|
|
67
|
+
"ox": "^0.12.4"
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=18.0.0"
|
|
71
|
+
}
|
|
72
|
+
}
|