apow-cli 0.11.18 → 0.12.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/dist/wallet.js CHANGED
@@ -6,15 +6,15 @@ exports.getFundingClients = getFundingClients;
6
6
  exports.requireWallet = requireWallet;
7
7
  exports.getEthBalance = getEthBalance;
8
8
  const viem_1 = require("viem");
9
- const accounts_1 = require("viem/accounts");
10
9
  const erc8021_1 = require("ox/erc8021");
11
10
  const config_1 = require("./config");
11
+ const local_keystore_1 = require("./signer/local-keystore");
12
12
  const x402_1 = require("./x402");
13
13
  const DATA_SUFFIX = erc8021_1.Attribution.toDataSuffix({ codes: ["bc_6wfeb1kd"] });
14
- const BASE_BOOTSTRAP_RPC_URL = "https://mainnet.base.org";
15
14
  function getTransport() {
16
- if (config_1.config.useX402 && config_1.config.privateKey) {
17
- return (0, x402_1.createX402Transport)(config_1.config.privateKey);
15
+ const signer = (0, local_keystore_1.getSigner)();
16
+ if (config_1.config.useX402 && signer) {
17
+ return (0, x402_1.createX402Transport)(signer.account);
18
18
  }
19
19
  return (0, viem_1.http)(config_1.config.rpcUrl);
20
20
  }
@@ -23,9 +23,7 @@ exports.publicClient = (0, viem_1.createPublicClient)({
23
23
  chain: config_1.config.chain,
24
24
  transport,
25
25
  });
26
- exports.account = config_1.config.privateKey
27
- ? (0, accounts_1.privateKeyToAccount)(config_1.config.privateKey)
28
- : null;
26
+ exports.account = (0, local_keystore_1.getSigner)()?.account ?? null;
29
27
  exports.walletClient = exports.account
30
28
  ? (0, viem_1.createWalletClient)({
31
29
  account: exports.account,
@@ -36,28 +34,28 @@ exports.walletClient = exports.account
36
34
  : null;
37
35
  let bootstrapPublicClient = (0, viem_1.createPublicClient)({
38
36
  chain: config_1.config.chain,
39
- transport: (0, viem_1.http)(BASE_BOOTSTRAP_RPC_URL),
37
+ transport: getBootstrapTransport(),
40
38
  });
41
- let bootstrapAccount = config_1.config.privateKey
42
- ? (0, accounts_1.privateKeyToAccount)(config_1.config.privateKey)
43
- : null;
39
+ let bootstrapAccount = (0, local_keystore_1.getSigner)()?.account ?? null;
44
40
  let bootstrapWalletClient = bootstrapAccount
45
41
  ? (0, viem_1.createWalletClient)({
46
42
  account: bootstrapAccount,
47
43
  chain: config_1.config.chain,
48
- transport: (0, viem_1.http)(BASE_BOOTSTRAP_RPC_URL),
44
+ transport: getBootstrapTransport(),
49
45
  dataSuffix: DATA_SUFFIX,
50
46
  })
51
47
  : null;
52
48
  function shouldUseBootstrapFundingClients() {
53
- return config_1.config.useX402 && config_1.config.chainName === "base";
49
+ return config_1.config.useX402 && config_1.config.chainName === "base" && !!config_1.config.rpcUrl;
50
+ }
51
+ function getBootstrapTransport() {
52
+ return config_1.config.rpcUrl ? (0, viem_1.http)(config_1.config.rpcUrl) : transport;
54
53
  }
55
54
  /** Reinitialize clients after config changes (e.g., x402 fallback). */
56
55
  function reinitClients() {
56
+ (0, local_keystore_1.resetSigner)();
57
57
  transport = getTransport();
58
- exports.account = config_1.config.privateKey
59
- ? (0, accounts_1.privateKeyToAccount)(config_1.config.privateKey)
60
- : null;
58
+ exports.account = (0, local_keystore_1.getSigner)()?.account ?? null;
61
59
  exports.publicClient = (0, viem_1.createPublicClient)({ chain: config_1.config.chain, transport });
62
60
  exports.walletClient = exports.account
63
61
  ? (0, viem_1.createWalletClient)({
@@ -69,16 +67,14 @@ function reinitClients() {
69
67
  : null;
70
68
  bootstrapPublicClient = (0, viem_1.createPublicClient)({
71
69
  chain: config_1.config.chain,
72
- transport: (0, viem_1.http)(BASE_BOOTSTRAP_RPC_URL),
70
+ transport: getBootstrapTransport(),
73
71
  });
74
- bootstrapAccount = config_1.config.privateKey
75
- ? (0, accounts_1.privateKeyToAccount)(config_1.config.privateKey)
76
- : null;
72
+ bootstrapAccount = (0, local_keystore_1.getSigner)()?.account ?? null;
77
73
  bootstrapWalletClient = bootstrapAccount
78
74
  ? (0, viem_1.createWalletClient)({
79
75
  account: bootstrapAccount,
80
76
  chain: config_1.config.chain,
81
- transport: (0, viem_1.http)(BASE_BOOTSTRAP_RPC_URL),
77
+ transport: getBootstrapTransport(),
82
78
  dataSuffix: DATA_SUFFIX,
83
79
  })
84
80
  : null;
@@ -95,7 +91,7 @@ function getFundingClients() {
95
91
  }
96
92
  function requireWallet() {
97
93
  if (!exports.account || !exports.walletClient) {
98
- throw new Error("Wallet is not configured. Set PRIVATE_KEY in .env.");
94
+ throw new Error("Wallet is not configured. Set KEYSTORE_PATH to an encrypted keystore and unlock it with KEYSTORE_PASSWORD.");
99
95
  }
100
96
  return { account: exports.account, walletClient: exports.walletClient };
101
97
  }
package/dist/x402.js CHANGED
@@ -40,22 +40,22 @@ const QUICKNODE_BASE = "https://x402.quicknode.com";
40
40
  const BASE_MAINNET = "eip155:8453";
41
41
  const X402_RPC_TIMEOUT_MS = 10_000;
42
42
  let _client = null;
43
- async function getClient(privateKey) {
43
+ async function getClient(account) {
44
44
  if (_client && !_client.isTokenExpired())
45
45
  return _client;
46
46
  const { createQuicknodeX402Client } = await Promise.resolve().then(() => __importStar(require("@quicknode/x402")));
47
47
  _client = await createQuicknodeX402Client({
48
48
  baseUrl: QUICKNODE_BASE,
49
49
  network: BASE_MAINNET,
50
- evmPrivateKey: privateKey,
50
+ evmSigner: account,
51
51
  paymentModel: "pay-per-request",
52
52
  });
53
53
  return _client;
54
54
  }
55
- function createX402Transport(privateKey) {
55
+ function createX402Transport(account) {
56
56
  return (0, viem_1.custom)({
57
57
  async request({ method, params }) {
58
- const client = await getClient(privateKey);
58
+ const client = await getClient(account);
59
59
  const response = await client.fetch(`${QUICKNODE_BASE}/base-mainnet`, {
60
60
  method: "POST",
61
61
  headers: { "Content-Type": "application/json" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apow-cli",
3
- "version": "0.11.18",
3
+ "version": "0.12.0",
4
4
  "description": "Mine AGENT tokens on Base L2 with Agentic Proof of Work",
5
5
  "keywords": [
6
6
  "apow",
@@ -18,7 +18,10 @@
18
18
  "type": "git",
19
19
  "url": "https://github.com/Agentoshi/apow-cli.git"
20
20
  },
21
- "homepage": "https://github.com/Agentoshi/apow-cli",
21
+ "homepage": "https://apow.io",
22
+ "bugs": {
23
+ "url": "https://github.com/Agentoshi/apow-cli/issues"
24
+ },
22
25
  "bin": {
23
26
  "apow": "dist/index.js",
24
27
  "apow-cli": "dist/index.js"
@@ -42,13 +45,13 @@
42
45
  "scripts": {
43
46
  "build": "tsc",
44
47
  "dev": "tsx src/index.ts",
48
+ "test": "tsx --test \"src/**/*.test.ts\"",
45
49
  "prepublishOnly": "npm run build"
46
50
  },
47
51
  "dependencies": {
48
- "@blockrun/clawrouter": "^0.12.81",
52
+ "@blockrun/clawrouter": "0.12.81",
49
53
  "@noble/hashes": "^1.8.0",
50
54
  "@quicknode/x402": "^0.1.2",
51
- "@solana/web3.js": "^1.98.0",
52
55
  "@x402/evm": "^2.8.0",
53
56
  "@x402/fetch": "^2.8.0",
54
57
  "commander": "^14.0.0",
@@ -60,7 +63,7 @@
60
63
  },
61
64
  "devDependencies": {
62
65
  "@types/node": "^24.6.0",
63
- "tsx": "^4.20.5",
66
+ "tsx": "^4.23.1",
64
67
  "typescript": "^5.9.3"
65
68
  }
66
69
  }