nodpay 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/propose.mjs +19 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodpay",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "NodPay CLI — propose on-chain payments from agent-human shared wallets",
5
5
  "type": "module",
6
6
  "bin": {
@@ -59,11 +59,7 @@ if (chainArg) {
59
59
  RPC_URL = net.rpcUrl;
60
60
  CHAIN_ID = String(net.chainId);
61
61
  } else {
62
- RPC_URL = process.env.RPC_URL;
63
- CHAIN_ID = process.env.CHAIN_ID;
64
- }
65
- if (!RPC_URL || !CHAIN_ID) {
66
- console.error('Error: Specify --chain <name> or set RPC_URL + CHAIN_ID env vars.\nSupported chains: ' + Object.keys(allChains).join(', '));
62
+ console.error('Error: --chain is required.\nSupported: ' + Object.keys(allChains).join(', '));
67
63
  process.exit(1);
68
64
  }
69
65
  const ENTRYPOINT_ADDRESS = ENTRYPOINT;
@@ -87,14 +83,27 @@ function loadAgentKey() {
87
83
  return null;
88
84
  }
89
85
  const NODPAY_AGENT_KEY = loadAgentKey();
90
- const DEFAULT_SAFE = process.env.SAFE_ADDRESS;
86
+ const DEFAULT_SAFE = null; // always use --safe flag
91
87
 
92
88
  // BUNDLER: NodPay provides a public bundler proxy at nodpay.ai/api/bundler so
93
89
  // agents don't need their own bundler API key. This is a thin relay — it
94
90
  // forwards the UserOp to a bundler service and returns the result. The proxy
95
91
  // only sees the already-signed (partial) UserOp; it cannot modify or execute it.
96
- // For self-hosted setups, override with OP_STORE_URL env var.
97
- const opStoreBase = process.env.OP_STORE_URL || 'https://nodpay.ai/api';
92
+ // For self-hosted setups, set OP_STORE_URL in .nodpay/.env.
93
+ function loadDotEnvVar(name, fallback) {
94
+ try {
95
+ const envPath = join(process.cwd(), '.nodpay', '.env');
96
+ const lines = readFileSync(envPath, 'utf8').split('\n');
97
+ for (const line of lines) {
98
+ const trimmed = line.trim();
99
+ if (trimmed.startsWith('#') || !trimmed.includes('=')) continue;
100
+ const [k, ...rest] = trimmed.split('=');
101
+ if (k.trim() === name) return rest.join('=').trim().replace(/^["']|["']$/g, '');
102
+ }
103
+ } catch {}
104
+ return fallback;
105
+ }
106
+ const opStoreBase = loadDotEnvVar('OP_STORE_URL', 'https://nodpay.ai/api');
98
107
  const BUNDLER_URL = `${opStoreBase}/bundler/${CHAIN_ID}`;
99
108
 
100
109
  if (!NODPAY_AGENT_KEY) {
@@ -324,7 +333,7 @@ try {
324
333
  const customNonceArg = getArg('--nonce');
325
334
  const reuseGasFrom = getArg('--reuse-gas-from'); // shortHash of a previous op to copy gas values from
326
335
  let txOptions = {};
327
- const opStoreUrl = process.env.OP_STORE_URL || 'https://nodpay.ai/api';
336
+ const opStoreUrl = opStoreBase;
328
337
  const safeAddr = await safe4337Pack.protocolKit.getAddress();
329
338
 
330
339
  // Determine nonce: on-chain nonce is the source of truth.
@@ -510,7 +519,7 @@ try {
510
519
  result.opStoreError = storeData.error || `HTTP ${storeRes.status}`;
511
520
  }
512
521
  if (storeData.shortHash) {
513
- const webBase = process.env.WEB_APP_URL || 'https://nodpay.ai/';
522
+ const webBase = loadDotEnvVar('WEB_APP_URL', 'https://nodpay.ai/');
514
523
  const purposeParam = purpose && purpose !== 'Unspecified' ? `&purpose=${encodeURIComponent(purpose)}` : '';
515
524
  approveUrl = `${webBase}approve?safeOpHash=${storeData.safeOpHash}${purposeParam}`;
516
525
  result.approveUrl = approveUrl;