moltspay 0.8.1 → 0.8.3

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/index.js CHANGED
@@ -2905,7 +2905,7 @@ function alphabet(letters) {
2905
2905
  };
2906
2906
  }
2907
2907
  // @__NO_SIDE_EFFECTS__
2908
- function join3(separator = "") {
2908
+ function join4(separator = "") {
2909
2909
  astr("join", separator);
2910
2910
  return {
2911
2911
  encode: (from) => {
@@ -3112,10 +3112,10 @@ var init_esm = __esm({
3112
3112
  convertRadix2,
3113
3113
  radix,
3114
3114
  radix2,
3115
- join: join3,
3115
+ join: join4,
3116
3116
  padding
3117
3117
  };
3118
- genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join3(""));
3118
+ genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join4(""));
3119
3119
  base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
3120
3120
  createBase58check = (sha2566) => /* @__PURE__ */ chain(checksum(4, (data) => sha2566(sha2566(data))), base58);
3121
3121
  }
@@ -3263,14 +3263,14 @@ var init_esm2 = __esm({
3263
3263
  }
3264
3264
  this.pubHash = hash160(this.pubKey);
3265
3265
  }
3266
- derive(path2) {
3267
- if (!/^[mM]'?/.test(path2)) {
3266
+ derive(path3) {
3267
+ if (!/^[mM]'?/.test(path3)) {
3268
3268
  throw new Error('Path must start with "m" or "M"');
3269
3269
  }
3270
- if (/^[mM]'?$/.test(path2)) {
3270
+ if (/^[mM]'?$/.test(path3)) {
3271
3271
  return this;
3272
3272
  }
3273
- const parts = path2.replace(/^[mM]'?\//, "").split("/");
3273
+ const parts = path3.replace(/^[mM]'?\//, "").split("/");
3274
3274
  let child = this;
3275
3275
  for (const c of parts) {
3276
3276
  const m = /^(\d+)('?)$/.exec(c);
@@ -9631,8 +9631,8 @@ var init_privateKeyToAccount = __esm({
9631
9631
  });
9632
9632
 
9633
9633
  // node_modules/viem/_esm/accounts/hdKeyToAccount.js
9634
- function hdKeyToAccount(hdKey_, { accountIndex = 0, addressIndex = 0, changeIndex = 0, path: path2, ...options } = {}) {
9635
- const hdKey = hdKey_.derive(path2 || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`);
9634
+ function hdKeyToAccount(hdKey_, { accountIndex = 0, addressIndex = 0, changeIndex = 0, path: path3, ...options } = {}) {
9635
+ const hdKey = hdKey_.derive(path3 || `m/44'/60'/${accountIndex}'/${changeIndex}/${addressIndex}`);
9636
9636
  const account = privateKeyToAccount(toHex(hdKey.privateKey), options);
9637
9637
  return {
9638
9638
  ...account,
@@ -30369,84 +30369,7 @@ init_cjs_shims();
30369
30369
  init_cjs_shims();
30370
30370
  var import_fs = require("fs");
30371
30371
  var import_http = require("http");
30372
-
30373
- // src/chains/index.ts
30374
- init_cjs_shims();
30375
- var CHAINS = {
30376
- // ============ Mainnet ============
30377
- base: {
30378
- name: "Base",
30379
- chainId: 8453,
30380
- rpc: "https://mainnet.base.org",
30381
- usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
30382
- explorer: "https://basescan.org/address/",
30383
- explorerTx: "https://basescan.org/tx/",
30384
- avgBlockTime: 2
30385
- },
30386
- polygon: {
30387
- name: "Polygon",
30388
- chainId: 137,
30389
- rpc: "https://polygon-rpc.com",
30390
- usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
30391
- explorer: "https://polygonscan.com/address/",
30392
- explorerTx: "https://polygonscan.com/tx/",
30393
- avgBlockTime: 2
30394
- },
30395
- ethereum: {
30396
- name: "Ethereum",
30397
- chainId: 1,
30398
- rpc: "https://eth.llamarpc.com",
30399
- usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
30400
- explorer: "https://etherscan.io/address/",
30401
- explorerTx: "https://etherscan.io/tx/",
30402
- avgBlockTime: 12
30403
- },
30404
- // ============ Testnet ============
30405
- base_sepolia: {
30406
- name: "Base Sepolia",
30407
- chainId: 84532,
30408
- rpc: "https://sepolia.base.org",
30409
- usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
30410
- explorer: "https://sepolia.basescan.org/address/",
30411
- explorerTx: "https://sepolia.basescan.org/tx/",
30412
- avgBlockTime: 2
30413
- },
30414
- sepolia: {
30415
- name: "Sepolia",
30416
- chainId: 11155111,
30417
- rpc: "https://rpc.sepolia.org",
30418
- usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
30419
- explorer: "https://sepolia.etherscan.io/address/",
30420
- explorerTx: "https://sepolia.etherscan.io/tx/",
30421
- avgBlockTime: 12
30422
- }
30423
- };
30424
- function getChain(name) {
30425
- const config = CHAINS[name];
30426
- if (!config) {
30427
- throw new Error(`Unsupported chain: ${name}. Supported: ${Object.keys(CHAINS).join(", ")}`);
30428
- }
30429
- return config;
30430
- }
30431
- function listChains() {
30432
- return Object.keys(CHAINS);
30433
- }
30434
- function getChainById(chainId) {
30435
- return Object.values(CHAINS).find((c) => c.chainId === chainId);
30436
- }
30437
- var ERC20_ABI = [
30438
- "function balanceOf(address owner) view returns (uint256)",
30439
- "function transfer(address to, uint256 amount) returns (bool)",
30440
- "function approve(address spender, uint256 amount) returns (bool)",
30441
- "function allowance(address owner, address spender) view returns (uint256)",
30442
- "function decimals() view returns (uint8)",
30443
- "function symbol() view returns (string)",
30444
- "function name() view returns (string)",
30445
- "function nonces(address owner) view returns (uint256)",
30446
- "function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)",
30447
- "event Transfer(address indexed from, address indexed to, uint256 value)",
30448
- "event Approval(address indexed owner, address indexed spender, uint256 value)"
30449
- ];
30372
+ var path = __toESM(require("path"));
30450
30373
 
30451
30374
  // src/server/types.ts
30452
30375
  init_cjs_shims();
@@ -30456,24 +30379,100 @@ var X402_VERSION = 2;
30456
30379
  var PAYMENT_REQUIRED_HEADER = "x-payment-required";
30457
30380
  var PAYMENT_HEADER = "x-payment";
30458
30381
  var PAYMENT_RESPONSE_HEADER = "x-payment-response";
30459
- var DEFAULT_FACILITATOR_URL = "https://x402.org/facilitator";
30382
+ var FACILITATOR_TESTNET = "https://www.x402.org/facilitator";
30383
+ var FACILITATOR_MAINNET = "https://api.cdp.coinbase.com/platform/v2/x402";
30384
+ var USDC_ADDRESSES = {
30385
+ "eip155:8453": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
30386
+ // Base mainnet
30387
+ "eip155:84532": "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
30388
+ // Base Sepolia
30389
+ };
30390
+ var USDC_DOMAIN = {
30391
+ name: "USD Coin",
30392
+ version: "2"
30393
+ };
30394
+ function loadEnvFiles() {
30395
+ try {
30396
+ const dotenv = require("dotenv");
30397
+ const envPaths = [
30398
+ path.join(process.cwd(), ".env"),
30399
+ path.join(process.env.HOME || "", ".moltspay", ".env")
30400
+ ];
30401
+ for (const envPath of envPaths) {
30402
+ if ((0, import_fs.existsSync)(envPath)) {
30403
+ dotenv.config({ path: envPath });
30404
+ console.log(`[MoltsPay] Loaded config from ${envPath}`);
30405
+ break;
30406
+ }
30407
+ }
30408
+ } catch {
30409
+ }
30410
+ }
30411
+ function getCDPConfig() {
30412
+ loadEnvFiles();
30413
+ return {
30414
+ useMainnet: process.env.USE_MAINNET?.toLowerCase() === "true",
30415
+ apiKeyId: process.env.CDP_API_KEY_ID,
30416
+ apiKeySecret: process.env.CDP_API_KEY_SECRET
30417
+ };
30418
+ }
30419
+ async function getCDPAuthHeaders(method, urlPath, body) {
30420
+ const config = getCDPConfig();
30421
+ if (!config.apiKeyId || !config.apiKeySecret) {
30422
+ throw new Error("CDP_API_KEY_ID and CDP_API_KEY_SECRET required for mainnet");
30423
+ }
30424
+ try {
30425
+ const { getAuthHeaders } = await import("@coinbase/cdp-sdk/auth");
30426
+ const headers = await getAuthHeaders({
30427
+ apiKeyId: config.apiKeyId,
30428
+ apiKeySecret: config.apiKeySecret,
30429
+ requestMethod: method,
30430
+ requestHost: "api.cdp.coinbase.com",
30431
+ requestPath: urlPath,
30432
+ requestBody: body
30433
+ });
30434
+ return headers;
30435
+ } catch (err) {
30436
+ console.error("[MoltsPay] Failed to generate CDP auth headers:", err.message);
30437
+ throw err;
30438
+ }
30439
+ }
30460
30440
  var MoltsPayServer = class {
30461
30441
  manifest;
30462
30442
  skills = /* @__PURE__ */ new Map();
30463
30443
  options;
30444
+ cdpConfig;
30464
30445
  facilitatorUrl;
30446
+ networkId;
30465
30447
  constructor(servicesPath, options = {}) {
30448
+ this.cdpConfig = getCDPConfig();
30466
30449
  const content = (0, import_fs.readFileSync)(servicesPath, "utf-8");
30467
30450
  this.manifest = JSON.parse(content);
30468
30451
  this.options = {
30469
30452
  port: options.port || 3e3,
30470
30453
  host: options.host || "0.0.0.0"
30471
30454
  };
30472
- this.facilitatorUrl = options.facilitatorUrl || DEFAULT_FACILITATOR_URL;
30455
+ if (this.cdpConfig.useMainnet) {
30456
+ if (!this.cdpConfig.apiKeyId || !this.cdpConfig.apiKeySecret) {
30457
+ console.warn("[MoltsPay] WARNING: USE_MAINNET=true but CDP keys not set!");
30458
+ console.warn("[MoltsPay] Set CDP_API_KEY_ID and CDP_API_KEY_SECRET in ~/.moltspay/.env");
30459
+ }
30460
+ this.facilitatorUrl = FACILITATOR_MAINNET;
30461
+ this.networkId = "eip155:8453";
30462
+ } else {
30463
+ this.facilitatorUrl = options.facilitatorUrl || FACILITATOR_TESTNET;
30464
+ this.networkId = "eip155:84532";
30465
+ }
30466
+ const networkName = this.cdpConfig.useMainnet ? "Base mainnet" : "Base Sepolia (testnet)";
30467
+ const facilitatorName = this.cdpConfig.useMainnet ? "CDP" : "x402.org";
30473
30468
  console.log(`[MoltsPay] Loaded ${this.manifest.services.length} services from ${servicesPath}`);
30474
30469
  console.log(`[MoltsPay] Provider: ${this.manifest.provider.name}`);
30475
30470
  console.log(`[MoltsPay] Receive wallet: ${this.manifest.provider.wallet}`);
30476
- console.log(`[MoltsPay] Facilitator: ${this.facilitatorUrl}`);
30471
+ console.log(`[MoltsPay] Network: ${this.networkId} (${networkName})`);
30472
+ console.log(`[MoltsPay] Facilitator: ${facilitatorName} (${this.facilitatorUrl})`);
30473
+ if (this.cdpConfig.useMainnet && this.cdpConfig.apiKeyId) {
30474
+ console.log(`[MoltsPay] CDP API Key: ${this.cdpConfig.apiKeyId.slice(0, 8)}...`);
30475
+ }
30477
30476
  console.log(`[MoltsPay] Protocol: x402 (gasless for both client AND server)`);
30478
30477
  }
30479
30478
  /**
@@ -30534,7 +30533,6 @@ var MoltsPayServer = class {
30534
30533
  * GET /services - List available services
30535
30534
  */
30536
30535
  handleGetServices(res) {
30537
- const chain2 = getChain(this.manifest.provider.chain);
30538
30536
  const services = this.manifest.services.map((s) => ({
30539
30537
  id: s.id,
30540
30538
  name: s.name,
@@ -30550,16 +30548,15 @@ var MoltsPayServer = class {
30550
30548
  services,
30551
30549
  x402: {
30552
30550
  version: X402_VERSION,
30553
- network: `eip155:${chain2.chainId}`,
30551
+ network: this.networkId,
30554
30552
  schemes: ["exact"],
30555
- facilitator: this.facilitatorUrl
30553
+ facilitator: this.cdpConfig.useMainnet ? "cdp" : "x402.org",
30554
+ mainnet: this.cdpConfig.useMainnet
30556
30555
  }
30557
30556
  });
30558
30557
  }
30559
30558
  /**
30560
30559
  * POST /execute - Execute service with x402 payment
30561
- * Body: { service: string, params: object }
30562
- * Header: X-Payment (optional - if missing, returns 402)
30563
30560
  */
30564
30561
  async handleExecute(body, paymentHeader, res) {
30565
30562
  const { service, params } = body;
@@ -30634,17 +30631,8 @@ var MoltsPayServer = class {
30634
30631
  * Return 402 with x402 payment requirements
30635
30632
  */
30636
30633
  sendPaymentRequired(config, res) {
30637
- const chain2 = getChain(this.manifest.provider.chain);
30638
- const amountInUnits = Math.floor(config.price * 1e6).toString();
30639
- const requirements = [{
30640
- scheme: "exact",
30641
- network: `eip155:${chain2.chainId}`,
30642
- maxAmountRequired: amountInUnits,
30643
- resource: this.manifest.provider.wallet,
30644
- description: `${config.name} - $${config.price} ${config.currency}`,
30645
- // Include facilitator info for client
30646
- extra: JSON.stringify({ facilitator: this.facilitatorUrl })
30647
- }];
30634
+ const requirements = [this.buildPaymentRequirements(config)];
30635
+ requirements[0].description = `${config.name} - $${config.price} ${config.currency}`;
30648
30636
  const encoded = Buffer.from(JSON.stringify(requirements)).toString("base64");
30649
30637
  res.writeHead(402, {
30650
30638
  "Content-Type": "application/json",
@@ -30657,7 +30645,7 @@ var MoltsPayServer = class {
30657
30645
  }, null, 2));
30658
30646
  }
30659
30647
  /**
30660
- * Basic payment validation (before calling facilitator)
30648
+ * Basic payment validation
30661
30649
  */
30662
30650
  validatePayment(payment, config) {
30663
30651
  if (payment.x402Version !== X402_VERSION) {
@@ -30666,37 +30654,57 @@ var MoltsPayServer = class {
30666
30654
  if (payment.scheme !== "exact") {
30667
30655
  return { valid: false, error: `Unsupported scheme: ${payment.scheme}` };
30668
30656
  }
30669
- const chain2 = getChain(this.manifest.provider.chain);
30670
- const expectedNetwork = `eip155:${chain2.chainId}`;
30671
- if (payment.network !== expectedNetwork) {
30672
- return { valid: false, error: `Network mismatch: expected ${expectedNetwork}` };
30657
+ if (payment.network !== this.networkId) {
30658
+ return { valid: false, error: `Network mismatch: expected ${this.networkId}, got ${payment.network}` };
30673
30659
  }
30674
30660
  return { valid: true };
30675
30661
  }
30676
30662
  /**
30677
- * Verify payment with facilitator
30663
+ * Build complete payment requirements for facilitator
30664
+ */
30665
+ buildPaymentRequirements(config) {
30666
+ const amountInUnits = Math.floor(config.price * 1e6).toString();
30667
+ const usdcAddress = USDC_ADDRESSES[this.networkId];
30668
+ return {
30669
+ scheme: "exact",
30670
+ network: this.networkId,
30671
+ maxAmountRequired: amountInUnits,
30672
+ amount: amountInUnits,
30673
+ asset: usdcAddress,
30674
+ payTo: this.manifest.provider.wallet,
30675
+ maxTimeoutSeconds: 300,
30676
+ extra: USDC_DOMAIN
30677
+ };
30678
+ }
30679
+ /**
30680
+ * Verify payment with facilitator (testnet or CDP)
30678
30681
  */
30679
30682
  async verifyWithFacilitator(payment, config) {
30680
30683
  try {
30681
- const chain2 = getChain(this.manifest.provider.chain);
30682
- const amountInUnits = Math.floor(config.price * 1e6).toString();
30683
- const requirements = {
30684
- scheme: "exact",
30685
- network: `eip155:${chain2.chainId}`,
30686
- maxAmountRequired: amountInUnits,
30687
- resource: this.manifest.provider.wallet
30684
+ const requirements = this.buildPaymentRequirements(config);
30685
+ const requestBody = {
30686
+ paymentPayload: payment,
30687
+ paymentRequirements: requirements
30688
30688
  };
30689
+ console.log("[MoltsPay] Verify request:", JSON.stringify(requestBody, null, 2));
30690
+ let headers = { "Content-Type": "application/json" };
30691
+ if (this.cdpConfig.useMainnet) {
30692
+ const authHeaders = await getCDPAuthHeaders(
30693
+ "POST",
30694
+ "/platform/v2/x402/verify",
30695
+ requestBody
30696
+ );
30697
+ headers = { ...headers, ...authHeaders };
30698
+ }
30689
30699
  const response = await fetch(`${this.facilitatorUrl}/verify`, {
30690
30700
  method: "POST",
30691
- headers: { "Content-Type": "application/json" },
30692
- body: JSON.stringify({
30693
- paymentPayload: payment,
30694
- paymentRequirements: requirements
30695
- })
30701
+ headers,
30702
+ body: JSON.stringify(requestBody)
30696
30703
  });
30697
30704
  const result = await response.json();
30705
+ console.log("[MoltsPay] Verify response:", JSON.stringify(result, null, 2));
30698
30706
  if (!response.ok || !result.isValid) {
30699
- return { valid: false, error: result.invalidReason || "Verification failed" };
30707
+ return { valid: false, error: result.invalidReason || result.error || "Verification failed" };
30700
30708
  }
30701
30709
  return { valid: true };
30702
30710
  } catch (err) {
@@ -30707,25 +30715,28 @@ var MoltsPayServer = class {
30707
30715
  * Settle payment with facilitator (execute on-chain transfer)
30708
30716
  */
30709
30717
  async settleWithFacilitator(payment, config) {
30710
- const chain2 = getChain(this.manifest.provider.chain);
30711
- const amountInUnits = Math.floor(config.price * 1e6).toString();
30712
- const requirements = {
30713
- scheme: "exact",
30714
- network: `eip155:${chain2.chainId}`,
30715
- maxAmountRequired: amountInUnits,
30716
- resource: this.manifest.provider.wallet
30718
+ const requirements = this.buildPaymentRequirements(config);
30719
+ const requestBody = {
30720
+ paymentPayload: payment,
30721
+ paymentRequirements: requirements
30717
30722
  };
30723
+ let headers = { "Content-Type": "application/json" };
30724
+ if (this.cdpConfig.useMainnet) {
30725
+ const authHeaders = await getCDPAuthHeaders(
30726
+ "POST",
30727
+ "/platform/v2/x402/settle",
30728
+ requestBody
30729
+ );
30730
+ headers = { ...headers, ...authHeaders };
30731
+ }
30718
30732
  const response = await fetch(`${this.facilitatorUrl}/settle`, {
30719
30733
  method: "POST",
30720
- headers: { "Content-Type": "application/json" },
30721
- body: JSON.stringify({
30722
- paymentPayload: payment,
30723
- paymentRequirements: requirements
30724
- })
30734
+ headers,
30735
+ body: JSON.stringify(requestBody)
30725
30736
  });
30726
30737
  const result = await response.json();
30727
- if (!response.ok) {
30728
- throw new Error(result.error || "Settlement failed");
30738
+ if (!response.ok || !result.success) {
30739
+ throw new Error(result.error || result.errorReason || "Settlement failed");
30729
30740
  }
30730
30741
  return {
30731
30742
  transaction: result.transaction,
@@ -30763,6 +30774,84 @@ var import_os = require("os");
30763
30774
  var import_path = require("path");
30764
30775
  var import_ethers = require("ethers");
30765
30776
 
30777
+ // src/chains/index.ts
30778
+ init_cjs_shims();
30779
+ var CHAINS = {
30780
+ // ============ Mainnet ============
30781
+ base: {
30782
+ name: "Base",
30783
+ chainId: 8453,
30784
+ rpc: "https://mainnet.base.org",
30785
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
30786
+ explorer: "https://basescan.org/address/",
30787
+ explorerTx: "https://basescan.org/tx/",
30788
+ avgBlockTime: 2
30789
+ },
30790
+ polygon: {
30791
+ name: "Polygon",
30792
+ chainId: 137,
30793
+ rpc: "https://polygon-rpc.com",
30794
+ usdc: "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
30795
+ explorer: "https://polygonscan.com/address/",
30796
+ explorerTx: "https://polygonscan.com/tx/",
30797
+ avgBlockTime: 2
30798
+ },
30799
+ ethereum: {
30800
+ name: "Ethereum",
30801
+ chainId: 1,
30802
+ rpc: "https://eth.llamarpc.com",
30803
+ usdc: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
30804
+ explorer: "https://etherscan.io/address/",
30805
+ explorerTx: "https://etherscan.io/tx/",
30806
+ avgBlockTime: 12
30807
+ },
30808
+ // ============ Testnet ============
30809
+ base_sepolia: {
30810
+ name: "Base Sepolia",
30811
+ chainId: 84532,
30812
+ rpc: "https://sepolia.base.org",
30813
+ usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
30814
+ explorer: "https://sepolia.basescan.org/address/",
30815
+ explorerTx: "https://sepolia.basescan.org/tx/",
30816
+ avgBlockTime: 2
30817
+ },
30818
+ sepolia: {
30819
+ name: "Sepolia",
30820
+ chainId: 11155111,
30821
+ rpc: "https://rpc.sepolia.org",
30822
+ usdc: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238",
30823
+ explorer: "https://sepolia.etherscan.io/address/",
30824
+ explorerTx: "https://sepolia.etherscan.io/tx/",
30825
+ avgBlockTime: 12
30826
+ }
30827
+ };
30828
+ function getChain(name) {
30829
+ const config = CHAINS[name];
30830
+ if (!config) {
30831
+ throw new Error(`Unsupported chain: ${name}. Supported: ${Object.keys(CHAINS).join(", ")}`);
30832
+ }
30833
+ return config;
30834
+ }
30835
+ function listChains() {
30836
+ return Object.keys(CHAINS);
30837
+ }
30838
+ function getChainById(chainId) {
30839
+ return Object.values(CHAINS).find((c) => c.chainId === chainId);
30840
+ }
30841
+ var ERC20_ABI = [
30842
+ "function balanceOf(address owner) view returns (uint256)",
30843
+ "function transfer(address to, uint256 amount) returns (bool)",
30844
+ "function approve(address spender, uint256 amount) returns (bool)",
30845
+ "function allowance(address owner, address spender) view returns (uint256)",
30846
+ "function decimals() view returns (uint8)",
30847
+ "function symbol() view returns (string)",
30848
+ "function name() view returns (string)",
30849
+ "function nonces(address owner) view returns (uint256)",
30850
+ "function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s)",
30851
+ "event Transfer(address indexed from, address indexed to, uint256 value)",
30852
+ "event Approval(address indexed owner, address indexed spender, uint256 value)"
30853
+ ];
30854
+
30766
30855
  // src/client/types.ts
30767
30856
  init_cjs_shims();
30768
30857
 
@@ -31145,20 +31234,20 @@ function loadWallet(options = {}) {
31145
31234
  }
31146
31235
  }
31147
31236
  function getWalletAddress(storagePath) {
31148
- const path2 = storagePath || (0, import_path2.join)(DEFAULT_STORAGE_DIR, DEFAULT_STORAGE_FILE);
31149
- if (!(0, import_fs3.existsSync)(path2)) {
31237
+ const path3 = storagePath || (0, import_path2.join)(DEFAULT_STORAGE_DIR, DEFAULT_STORAGE_FILE);
31238
+ if (!(0, import_fs3.existsSync)(path3)) {
31150
31239
  return null;
31151
31240
  }
31152
31241
  try {
31153
- const data = JSON.parse((0, import_fs3.readFileSync)(path2, "utf8"));
31242
+ const data = JSON.parse((0, import_fs3.readFileSync)(path3, "utf8"));
31154
31243
  return data.address;
31155
31244
  } catch {
31156
31245
  return null;
31157
31246
  }
31158
31247
  }
31159
31248
  function walletExists(storagePath) {
31160
- const path2 = storagePath || (0, import_path2.join)(DEFAULT_STORAGE_DIR, DEFAULT_STORAGE_FILE);
31161
- return (0, import_fs3.existsSync)(path2);
31249
+ const path3 = storagePath || (0, import_path2.join)(DEFAULT_STORAGE_DIR, DEFAULT_STORAGE_FILE);
31250
+ return (0, import_fs3.existsSync)(path3);
31162
31251
  }
31163
31252
 
31164
31253
  // src/verify/index.ts
@@ -31301,8 +31390,8 @@ async function waitForTransaction(txHash, chain2 = "base", confirmations = 1, ti
31301
31390
  // src/cdp/index.ts
31302
31391
  init_cjs_shims();
31303
31392
  var fs = __toESM(require("fs"));
31304
- var path = __toESM(require("path"));
31305
- var DEFAULT_STORAGE_DIR2 = path.join(process.env.HOME || ".", ".moltspay");
31393
+ var path2 = __toESM(require("path"));
31394
+ var DEFAULT_STORAGE_DIR2 = path2.join(process.env.HOME || ".", ".moltspay");
31306
31395
  var CDP_CONFIG_FILE = "cdp-wallet.json";
31307
31396
  function isCDPAvailable() {
31308
31397
  try {
@@ -31324,7 +31413,7 @@ function getCDPCredentials(config) {
31324
31413
  async function initCDPWallet(config = {}) {
31325
31414
  const storageDir = config.storageDir || DEFAULT_STORAGE_DIR2;
31326
31415
  const chain2 = config.chain || "base";
31327
- const storagePath = path.join(storageDir, CDP_CONFIG_FILE);
31416
+ const storagePath = path2.join(storageDir, CDP_CONFIG_FILE);
31328
31417
  if (fs.existsSync(storagePath)) {
31329
31418
  try {
31330
31419
  const data = JSON.parse(fs.readFileSync(storagePath, "utf-8"));
@@ -31386,7 +31475,7 @@ async function initCDPWallet(config = {}) {
31386
31475
  }
31387
31476
  function loadCDPWallet(config = {}) {
31388
31477
  const storageDir = config.storageDir || DEFAULT_STORAGE_DIR2;
31389
- const storagePath = path.join(storageDir, CDP_CONFIG_FILE);
31478
+ const storagePath = path2.join(storageDir, CDP_CONFIG_FILE);
31390
31479
  if (!fs.existsSync(storagePath)) {
31391
31480
  return null;
31392
31481
  }