x402-mantle-sdk 0.2.2 → 0.2.5

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.
@@ -25,6 +25,10 @@ interface PaymentModalProps {
25
25
  onComplete: (payment: PaymentResponse) => void;
26
26
  onCancel: () => void;
27
27
  isOpen: boolean;
28
+ /** Custom logo URL or base64 data URI */
29
+ logo?: string;
30
+ /** Logo alt text */
31
+ logoAlt?: string;
28
32
  }
29
33
  /**
30
34
  * Payment Modal Component
@@ -39,7 +43,7 @@ interface PaymentModalProps {
39
43
  * />
40
44
  * ```
41
45
  */
42
- declare function PaymentModal({ request, onComplete, onCancel, isOpen }: PaymentModalProps): react_jsx_runtime.JSX.Element | null;
46
+ declare function PaymentModal({ request, onComplete, onCancel, isOpen, logo, logoAlt }: PaymentModalProps): react_jsx_runtime.JSX.Element | null;
43
47
 
44
48
  interface EnhancedPaymentModalProps {
45
49
  request: PaymentRequest;
@@ -25,6 +25,10 @@ interface PaymentModalProps {
25
25
  onComplete: (payment: PaymentResponse) => void;
26
26
  onCancel: () => void;
27
27
  isOpen: boolean;
28
+ /** Custom logo URL or base64 data URI */
29
+ logo?: string;
30
+ /** Logo alt text */
31
+ logoAlt?: string;
28
32
  }
29
33
  /**
30
34
  * Payment Modal Component
@@ -39,7 +43,7 @@ interface PaymentModalProps {
39
43
  * />
40
44
  * ```
41
45
  */
42
- declare function PaymentModal({ request, onComplete, onCancel, isOpen }: PaymentModalProps): react_jsx_runtime.JSX.Element | null;
46
+ declare function PaymentModal({ request, onComplete, onCancel, isOpen, logo, logoAlt }: PaymentModalProps): react_jsx_runtime.JSX.Element | null;
43
47
 
44
48
  interface EnhancedPaymentModalProps {
45
49
  request: PaymentRequest;
@@ -86,9 +86,6 @@ var TOKENS = {
86
86
  }
87
87
  }
88
88
  };
89
- var TREASURY_ADDRESS = "0xB27705342ACE73736AE490540Ea031cc06C3eF49";
90
- var PLATFORM_FEE_BPS = 50n;
91
- var BPS_DENOMINATOR = 10000n;
92
89
  var customNetworks = /* @__PURE__ */ new Map();
93
90
  var customTokens = /* @__PURE__ */ new Map();
94
91
  function getNetworkConfig(network) {
@@ -291,11 +288,6 @@ function amountToWei(amount, decimals = 18) {
291
288
  const fraction = (parts[1] || "").padEnd(decimals, "0").slice(0, decimals);
292
289
  return BigInt(whole) * 10n ** BigInt(decimals) + BigInt(fraction);
293
290
  }
294
- function calculateSplit(amount) {
295
- const feeAmount = amount * PLATFORM_FEE_BPS / BPS_DENOMINATOR;
296
- const merchantAmount = amount - feeAmount;
297
- return { merchantAmount, feeAmount };
298
- }
299
291
  function encodeERC20Transfer(to, amount) {
300
292
  const toHex = to.slice(2).toLowerCase().padStart(64, "0");
301
293
  const amountHex = amount.toString(16).padStart(64, "0");
@@ -311,7 +303,6 @@ async function processPayment(request, wallet) {
311
303
  if (totalAmount === 0n) {
312
304
  throw new Error("Invalid payment amount: amount must be greater than 0");
313
305
  }
314
- const { merchantAmount, feeAmount } = calculateSplit(totalAmount);
315
306
  let txHash;
316
307
  if (tokenConfig) {
317
308
  const transferData = encodeERC20Transfer(request.recipient, totalAmount);
@@ -321,22 +312,12 @@ async function processPayment(request, wallet) {
321
312
  };
322
313
  txHash = await wallet.sendTransaction(tx);
323
314
  } else {
324
- const merchantValue = merchantAmount.toString(16);
325
- const merchantTx = {
315
+ const totalValue = totalAmount.toString(16);
316
+ const tx = {
326
317
  to: request.recipient,
327
- value: `0x${merchantValue}`
318
+ value: `0x${totalValue}`
328
319
  };
329
- txHash = await wallet.sendTransaction(merchantTx);
330
- if (feeAmount > 0n) {
331
- const feeValue = feeAmount.toString(16);
332
- const feeTx = {
333
- to: TREASURY_ADDRESS,
334
- value: `0x${feeValue}`
335
- };
336
- wallet.sendTransaction(feeTx).catch((err) => {
337
- console.warn("Fee transaction failed (non-critical):", err);
338
- });
339
- }
320
+ txHash = await wallet.sendTransaction(tx);
340
321
  }
341
322
  return {
342
323
  transactionHash: txHash,
@@ -346,6 +327,7 @@ async function processPayment(request, wallet) {
346
327
 
347
328
  // src/client/modal-react.tsx
348
329
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
330
+ var DEFAULT_LOGO = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cdefs%3E%3ClinearGradient id='bg' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' style='stop-color:%231a1a2e'/%3E%3Cstop offset='100%25' style='stop-color:%230f0f1a'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='120' height='120' rx='24' fill='url(%23bg)'/%3E%3Crect x='4' y='4' width='112' height='112' rx='20' fill='none' stroke='%23ffffff15' stroke-width='1'/%3E%3Ctext x='60' y='72' text-anchor='middle' font-family='-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif' font-size='32' font-weight='600' fill='%23ffffff'%3Ex402%3C/text%3E%3C/svg%3E`;
349
331
  function formatAddress(address) {
350
332
  if (!address || typeof address !== "string") {
351
333
  return "N/A";
@@ -355,7 +337,7 @@ function formatAddress(address) {
355
337
  }
356
338
  return `${address.slice(0, 6)}...${address.slice(-4)}`;
357
339
  }
358
- function PaymentModal({ request, onComplete, onCancel, isOpen }) {
340
+ function PaymentModal({ request, onComplete, onCancel, isOpen, logo, logoAlt = "x402" }) {
359
341
  const [walletAddress, setWalletAddress] = useState(null);
360
342
  const [isConnecting, setIsConnecting] = useState(false);
361
343
  const [isProcessing, setIsProcessing] = useState(false);
@@ -533,21 +515,16 @@ function PaymentModal({ request, onComplete, onCancel, isOpen }) {
533
515
  children: [
534
516
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
535
517
  /* @__PURE__ */ jsx(
536
- "div",
518
+ "img",
537
519
  {
520
+ src: logo || DEFAULT_LOGO,
521
+ alt: logoAlt,
538
522
  style: {
539
523
  width: "2rem",
540
524
  height: "2rem",
541
- display: "flex",
542
- alignItems: "center",
543
- justifyContent: "center",
544
525
  borderRadius: "0.5rem",
545
- background: "rgba(255, 255, 255, 0.1)",
546
- fontFamily: "monospace",
547
- fontSize: "0.75rem",
548
- fontWeight: "bold"
549
- },
550
- children: "x402"
526
+ objectFit: "contain"
527
+ }
551
528
  }
552
529
  ),
553
530
  /* @__PURE__ */ jsx("h2", { style: { margin: 0, fontSize: "1.25rem", fontWeight: 300 }, children: "Payment Required" })