x402-mantle-sdk 0.1.0 → 0.2.2
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/README.md +239 -44
- package/dist/client/index.cjs +40 -8
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +3 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +40 -8
- package/dist/client/index.js.map +1 -1
- package/dist/client/react.cjs +1178 -9
- package/dist/client/react.cjs.map +1 -1
- package/dist/client/react.d.cts +29 -1
- package/dist/client/react.d.ts +29 -1
- package/dist/client/react.js +1177 -9
- package/dist/client/react.js.map +1 -1
- package/dist/server/index.cjs +199 -43
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +80 -3
- package/dist/server/index.d.ts +80 -3
- package/dist/server/index.js +170 -16
- package/dist/server/index.js.map +1 -1
- package/package.json +15 -4
package/dist/client/react.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/client/react.ts
|
|
21
21
|
var react_exports = {};
|
|
22
22
|
__export(react_exports, {
|
|
23
|
+
EnhancedPaymentModal: () => EnhancedPaymentModal,
|
|
23
24
|
PaymentModal: () => PaymentModal
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(react_exports);
|
|
@@ -28,6 +29,32 @@ module.exports = __toCommonJS(react_exports);
|
|
|
28
29
|
var import_react = require("react");
|
|
29
30
|
|
|
30
31
|
// src/client/constants.ts
|
|
32
|
+
var NETWORKS = {
|
|
33
|
+
mantle: {
|
|
34
|
+
chainId: 5e3,
|
|
35
|
+
rpcUrl: "https://rpc.mantle.xyz",
|
|
36
|
+
name: "Mantle",
|
|
37
|
+
environment: "mainnet",
|
|
38
|
+
nativeCurrency: { name: "Mantle", symbol: "MNT", decimals: 18 },
|
|
39
|
+
blockExplorer: "https://explorer.mantle.xyz"
|
|
40
|
+
},
|
|
41
|
+
"mantle-sepolia": {
|
|
42
|
+
chainId: 5003,
|
|
43
|
+
rpcUrl: "https://rpc.sepolia.mantle.xyz",
|
|
44
|
+
name: "Mantle Sepolia",
|
|
45
|
+
environment: "testnet",
|
|
46
|
+
nativeCurrency: { name: "Mantle", symbol: "MNT", decimals: 18 },
|
|
47
|
+
blockExplorer: "https://explorer.sepolia.mantle.xyz"
|
|
48
|
+
},
|
|
49
|
+
"mantle-testnet": {
|
|
50
|
+
chainId: 5003,
|
|
51
|
+
rpcUrl: "https://rpc.sepolia.mantle.xyz",
|
|
52
|
+
name: "Mantle Testnet",
|
|
53
|
+
environment: "testnet",
|
|
54
|
+
nativeCurrency: { name: "Mantle", symbol: "MNT", decimals: 18 },
|
|
55
|
+
blockExplorer: "https://explorer.sepolia.mantle.xyz"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
31
58
|
var TOKENS = {
|
|
32
59
|
mantle: {
|
|
33
60
|
USDC: {
|
|
@@ -89,7 +116,20 @@ var TOKENS = {
|
|
|
89
116
|
var TREASURY_ADDRESS = "0xB27705342ACE73736AE490540Ea031cc06C3eF49";
|
|
90
117
|
var PLATFORM_FEE_BPS = 50n;
|
|
91
118
|
var BPS_DENOMINATOR = 10000n;
|
|
119
|
+
var customNetworks = /* @__PURE__ */ new Map();
|
|
92
120
|
var customTokens = /* @__PURE__ */ new Map();
|
|
121
|
+
function getNetworkConfig(network) {
|
|
122
|
+
const networkKey = network.toLowerCase();
|
|
123
|
+
const custom = customNetworks.get(networkKey);
|
|
124
|
+
if (custom) {
|
|
125
|
+
return custom;
|
|
126
|
+
}
|
|
127
|
+
const preset = NETWORKS[networkKey];
|
|
128
|
+
if (preset) {
|
|
129
|
+
return preset;
|
|
130
|
+
}
|
|
131
|
+
return NETWORKS.mantle;
|
|
132
|
+
}
|
|
93
133
|
function getTokenConfig(token, network) {
|
|
94
134
|
const networkKey = network.toLowerCase();
|
|
95
135
|
const tokenKey = token.toUpperCase();
|
|
@@ -186,11 +226,33 @@ var MetaMaskProvider = class {
|
|
|
186
226
|
if (!this.ethereum) {
|
|
187
227
|
throw new Error("MetaMask is not available");
|
|
188
228
|
}
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
229
|
+
const account = await this.getAccount();
|
|
230
|
+
if (!account) {
|
|
231
|
+
throw new Error("No account connected. Please connect your wallet first.");
|
|
232
|
+
}
|
|
233
|
+
const txWithFrom = {
|
|
234
|
+
...tx,
|
|
235
|
+
from: account
|
|
236
|
+
};
|
|
237
|
+
try {
|
|
238
|
+
const txHash = await this.ethereum.request({
|
|
239
|
+
method: "eth_sendTransaction",
|
|
240
|
+
params: [txWithFrom]
|
|
241
|
+
});
|
|
242
|
+
return txHash;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (error.code === 4001) {
|
|
245
|
+
throw new Error("Transaction rejected by user");
|
|
246
|
+
} else if (error.code === -32602) {
|
|
247
|
+
throw new Error("Invalid transaction parameters");
|
|
248
|
+
} else if (error.message?.includes("insufficient funds") || error.message?.includes("insufficient balance")) {
|
|
249
|
+
throw new Error("Insufficient funds for this transaction");
|
|
250
|
+
} else if (error.message) {
|
|
251
|
+
throw new Error(error.message);
|
|
252
|
+
} else {
|
|
253
|
+
throw new Error(`Transaction failed: ${error.code || "Unknown error"}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
194
256
|
}
|
|
195
257
|
async signMessage(message) {
|
|
196
258
|
if (!this.ethereum) {
|
|
@@ -223,6 +285,30 @@ async function connectWallet(provider) {
|
|
|
223
285
|
}
|
|
224
286
|
return wallet.connect();
|
|
225
287
|
}
|
|
288
|
+
async function ensureNetwork(wallet, network, autoAdd = true) {
|
|
289
|
+
const config = getNetworkConfig(network);
|
|
290
|
+
const targetChainId = config.chainId;
|
|
291
|
+
const currentChainId = await wallet.getChainId();
|
|
292
|
+
if (currentChainId === targetChainId) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
await wallet.switchNetwork(targetChainId);
|
|
297
|
+
} catch (error) {
|
|
298
|
+
const switchError = error;
|
|
299
|
+
if (autoAdd && switchError.message?.includes("not found")) {
|
|
300
|
+
await wallet.addNetwork({
|
|
301
|
+
chainId: `0x${targetChainId.toString(16)}`,
|
|
302
|
+
chainName: config.name,
|
|
303
|
+
nativeCurrency: config.nativeCurrency,
|
|
304
|
+
rpcUrls: [config.rpcUrl],
|
|
305
|
+
blockExplorerUrls: config.blockExplorer ? [config.blockExplorer] : void 0
|
|
306
|
+
});
|
|
307
|
+
} else {
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
226
312
|
|
|
227
313
|
// src/client/payment.ts
|
|
228
314
|
var ERC20_TRANSFER_SIG = "0xa9059cbb";
|
|
@@ -243,9 +329,15 @@ function encodeERC20Transfer(to, amount) {
|
|
|
243
329
|
return ERC20_TRANSFER_SIG + toHex + amountHex;
|
|
244
330
|
}
|
|
245
331
|
async function processPayment(request, wallet) {
|
|
332
|
+
if (!request.amount || !request.recipient || !request.network) {
|
|
333
|
+
throw new Error("Invalid payment request: missing required fields");
|
|
334
|
+
}
|
|
246
335
|
const tokenConfig = getTokenConfig(request.token, request.network);
|
|
247
336
|
const decimals = tokenConfig?.decimals ?? 18;
|
|
248
337
|
const totalAmount = amountToWei(request.amount, decimals);
|
|
338
|
+
if (totalAmount === 0n) {
|
|
339
|
+
throw new Error("Invalid payment amount: amount must be greater than 0");
|
|
340
|
+
}
|
|
249
341
|
const { merchantAmount, feeAmount } = calculateSplit(totalAmount);
|
|
250
342
|
let txHash;
|
|
251
343
|
if (tokenConfig) {
|
|
@@ -256,17 +348,21 @@ async function processPayment(request, wallet) {
|
|
|
256
348
|
};
|
|
257
349
|
txHash = await wallet.sendTransaction(tx);
|
|
258
350
|
} else {
|
|
351
|
+
const merchantValue = merchantAmount.toString(16);
|
|
259
352
|
const merchantTx = {
|
|
260
353
|
to: request.recipient,
|
|
261
|
-
value: `0x${
|
|
354
|
+
value: `0x${merchantValue}`
|
|
262
355
|
};
|
|
263
356
|
txHash = await wallet.sendTransaction(merchantTx);
|
|
264
357
|
if (feeAmount > 0n) {
|
|
358
|
+
const feeValue = feeAmount.toString(16);
|
|
265
359
|
const feeTx = {
|
|
266
360
|
to: TREASURY_ADDRESS,
|
|
267
|
-
value: `0x${
|
|
361
|
+
value: `0x${feeValue}`
|
|
268
362
|
};
|
|
269
|
-
|
|
363
|
+
wallet.sendTransaction(feeTx).catch((err) => {
|
|
364
|
+
console.warn("Fee transaction failed (non-critical):", err);
|
|
365
|
+
});
|
|
270
366
|
}
|
|
271
367
|
}
|
|
272
368
|
return {
|
|
@@ -278,6 +374,12 @@ async function processPayment(request, wallet) {
|
|
|
278
374
|
// src/client/modal-react.tsx
|
|
279
375
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
280
376
|
function formatAddress(address) {
|
|
377
|
+
if (!address || typeof address !== "string") {
|
|
378
|
+
return "N/A";
|
|
379
|
+
}
|
|
380
|
+
if (address.length < 10) {
|
|
381
|
+
return address;
|
|
382
|
+
}
|
|
281
383
|
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
282
384
|
}
|
|
283
385
|
function PaymentModal({ request, onComplete, onCancel, isOpen }) {
|
|
@@ -286,6 +388,62 @@ function PaymentModal({ request, onComplete, onCancel, isOpen }) {
|
|
|
286
388
|
const [isProcessing, setIsProcessing] = (0, import_react.useState)(false);
|
|
287
389
|
const [error, setError] = (0, import_react.useState)(null);
|
|
288
390
|
const [step, setStep] = (0, import_react.useState)("connect");
|
|
391
|
+
if (!request || !request.amount || !request.recipient || !request.network) {
|
|
392
|
+
console.error("Invalid payment request:", request);
|
|
393
|
+
if (isOpen) {
|
|
394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
style: {
|
|
398
|
+
position: "fixed",
|
|
399
|
+
inset: 0,
|
|
400
|
+
zIndex: 9999,
|
|
401
|
+
display: "flex",
|
|
402
|
+
alignItems: "center",
|
|
403
|
+
justifyContent: "center",
|
|
404
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
405
|
+
backdropFilter: "blur(4px)"
|
|
406
|
+
},
|
|
407
|
+
onClick: (e) => e.target === e.currentTarget && onCancel(),
|
|
408
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
409
|
+
"div",
|
|
410
|
+
{
|
|
411
|
+
style: {
|
|
412
|
+
width: "100%",
|
|
413
|
+
maxWidth: "28rem",
|
|
414
|
+
borderRadius: "0.75rem",
|
|
415
|
+
border: "1px solid rgba(239, 68, 68, 0.5)",
|
|
416
|
+
background: "rgba(24, 24, 27, 0.95)",
|
|
417
|
+
padding: "1.5rem",
|
|
418
|
+
color: "#fafafa"
|
|
419
|
+
},
|
|
420
|
+
children: [
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { style: { margin: "0 0 1rem 0", color: "rgba(239, 68, 68, 0.9)" }, children: "Invalid Payment Request" }),
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: { margin: "0 0 1rem 0", color: "rgba(250, 250, 250, 0.8)" }, children: "The payment request is missing required information. Please try again." }),
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
424
|
+
"button",
|
|
425
|
+
{
|
|
426
|
+
onClick: onCancel,
|
|
427
|
+
style: {
|
|
428
|
+
width: "100%",
|
|
429
|
+
padding: "0.75rem",
|
|
430
|
+
borderRadius: "0.5rem",
|
|
431
|
+
border: "1px solid rgba(255, 255, 255, 0.2)",
|
|
432
|
+
background: "rgba(255, 255, 255, 0.1)",
|
|
433
|
+
color: "#fafafa",
|
|
434
|
+
cursor: "pointer"
|
|
435
|
+
},
|
|
436
|
+
children: "Close"
|
|
437
|
+
}
|
|
438
|
+
)
|
|
439
|
+
]
|
|
440
|
+
}
|
|
441
|
+
)
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
289
447
|
const checkWalletConnection = (0, import_react.useCallback)(async () => {
|
|
290
448
|
const wallet = detectWalletProvider();
|
|
291
449
|
if (wallet) {
|
|
@@ -334,10 +492,27 @@ function PaymentModal({ request, onComplete, onCancel, isOpen }) {
|
|
|
334
492
|
if (!wallet) {
|
|
335
493
|
throw new Error("Wallet not connected");
|
|
336
494
|
}
|
|
495
|
+
try {
|
|
496
|
+
await ensureNetwork(wallet, request.network, true);
|
|
497
|
+
} catch (networkError) {
|
|
498
|
+
const errorMessage = networkError instanceof Error ? networkError.message : "Network switch failed";
|
|
499
|
+
throw new Error(`Failed to switch network: ${errorMessage}. Please ensure you're on ${request.network}`);
|
|
500
|
+
}
|
|
337
501
|
const payment = await processPayment(request, wallet);
|
|
338
502
|
onComplete(payment);
|
|
339
503
|
} catch (err) {
|
|
340
|
-
|
|
504
|
+
let errorMessage = "Payment failed";
|
|
505
|
+
if (err instanceof Error) {
|
|
506
|
+
errorMessage = err.message;
|
|
507
|
+
if (err.message.includes("user rejected") || err.message.includes("User denied")) {
|
|
508
|
+
errorMessage = "Transaction was rejected. Please try again.";
|
|
509
|
+
} else if (err.message.includes("insufficient funds") || err.message.includes("insufficient balance")) {
|
|
510
|
+
errorMessage = "Insufficient funds. Please ensure you have enough MNT in your wallet.";
|
|
511
|
+
} else if (err.message.includes("network")) {
|
|
512
|
+
errorMessage = err.message;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
setError(errorMessage);
|
|
341
516
|
setStep("confirm");
|
|
342
517
|
} finally {
|
|
343
518
|
setIsProcessing(false);
|
|
@@ -651,8 +826,1002 @@ function PaymentModal({ request, onComplete, onCancel, isOpen }) {
|
|
|
651
826
|
}
|
|
652
827
|
);
|
|
653
828
|
}
|
|
829
|
+
|
|
830
|
+
// src/client/payment-modal-enhanced.tsx
|
|
831
|
+
var import_react2 = require("react");
|
|
832
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
833
|
+
function formatAddress2(address) {
|
|
834
|
+
if (!address || typeof address !== "string") {
|
|
835
|
+
return "N/A";
|
|
836
|
+
}
|
|
837
|
+
if (address.length < 10) {
|
|
838
|
+
return address;
|
|
839
|
+
}
|
|
840
|
+
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
841
|
+
}
|
|
842
|
+
function getExplorerUrl(txHash, network) {
|
|
843
|
+
const config = getNetworkConfig(network);
|
|
844
|
+
if (config.blockExplorer) {
|
|
845
|
+
return `${config.blockExplorer}/tx/${txHash}`;
|
|
846
|
+
}
|
|
847
|
+
if (network.includes("sepolia") || network.includes("testnet")) {
|
|
848
|
+
return `https://explorer.sepolia.mantle.xyz/tx/${txHash}`;
|
|
849
|
+
}
|
|
850
|
+
return `https://explorer.mantle.xyz/tx/${txHash}`;
|
|
851
|
+
}
|
|
852
|
+
function EnhancedPaymentModal({
|
|
853
|
+
request,
|
|
854
|
+
onComplete,
|
|
855
|
+
onCancel,
|
|
856
|
+
isOpen,
|
|
857
|
+
simulation = false,
|
|
858
|
+
description,
|
|
859
|
+
endpoint
|
|
860
|
+
}) {
|
|
861
|
+
const [walletAddress, setWalletAddress] = (0, import_react2.useState)(null);
|
|
862
|
+
const [isConnecting, setIsConnecting] = (0, import_react2.useState)(false);
|
|
863
|
+
const [isProcessing, setIsProcessing] = (0, import_react2.useState)(false);
|
|
864
|
+
const [error, setError] = (0, import_react2.useState)(null);
|
|
865
|
+
const [txHash, setTxHash] = (0, import_react2.useState)(null);
|
|
866
|
+
const [copied, setCopied] = (0, import_react2.useState)(false);
|
|
867
|
+
(0, import_react2.useEffect)(() => {
|
|
868
|
+
if (!isOpen) {
|
|
869
|
+
setIsProcessing(false);
|
|
870
|
+
setError(null);
|
|
871
|
+
setTxHash(null);
|
|
872
|
+
setCopied(false);
|
|
873
|
+
setWalletAddress(null);
|
|
874
|
+
}
|
|
875
|
+
}, [isOpen]);
|
|
876
|
+
const handleCopy = (0, import_react2.useCallback)((text) => {
|
|
877
|
+
navigator.clipboard.writeText(text);
|
|
878
|
+
setCopied(true);
|
|
879
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
880
|
+
}, []);
|
|
881
|
+
const checkWalletConnection = (0, import_react2.useCallback)(async () => {
|
|
882
|
+
const wallet = detectWalletProvider();
|
|
883
|
+
if (wallet) {
|
|
884
|
+
try {
|
|
885
|
+
const account = await wallet.getAccount();
|
|
886
|
+
if (account) {
|
|
887
|
+
setWalletAddress(account);
|
|
888
|
+
}
|
|
889
|
+
} catch {
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}, []);
|
|
893
|
+
(0, import_react2.useEffect)(() => {
|
|
894
|
+
if (isOpen) {
|
|
895
|
+
checkWalletConnection();
|
|
896
|
+
}
|
|
897
|
+
}, [isOpen, checkWalletConnection]);
|
|
898
|
+
const handleConnect = async () => {
|
|
899
|
+
setIsConnecting(true);
|
|
900
|
+
setError(null);
|
|
901
|
+
try {
|
|
902
|
+
const wallet = detectWalletProvider();
|
|
903
|
+
if (!wallet) {
|
|
904
|
+
throw new Error("No wallet found. Please install MetaMask.");
|
|
905
|
+
}
|
|
906
|
+
const address = await connectWallet(wallet);
|
|
907
|
+
setWalletAddress(address);
|
|
908
|
+
} catch (err) {
|
|
909
|
+
setError(err instanceof Error ? err.message : "Failed to connect wallet");
|
|
910
|
+
} finally {
|
|
911
|
+
setIsConnecting(false);
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
const handlePayment = async () => {
|
|
915
|
+
if (simulation) {
|
|
916
|
+
setIsProcessing(true);
|
|
917
|
+
setError(null);
|
|
918
|
+
await new Promise((resolve) => setTimeout(resolve, 2e3));
|
|
919
|
+
const mockTxHash = `0x${Array.from(
|
|
920
|
+
{ length: 64 },
|
|
921
|
+
() => Math.floor(Math.random() * 16).toString(16)
|
|
922
|
+
).join("")}`;
|
|
923
|
+
setTxHash(mockTxHash);
|
|
924
|
+
setTimeout(() => {
|
|
925
|
+
const paymentResponse = {
|
|
926
|
+
transactionHash: mockTxHash,
|
|
927
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
928
|
+
};
|
|
929
|
+
setIsProcessing(false);
|
|
930
|
+
onComplete(paymentResponse);
|
|
931
|
+
}, 1500);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
if (!walletAddress) {
|
|
935
|
+
setError("Please connect your wallet first");
|
|
936
|
+
return;
|
|
937
|
+
}
|
|
938
|
+
try {
|
|
939
|
+
setIsProcessing(true);
|
|
940
|
+
setError(null);
|
|
941
|
+
const wallet = detectWalletProvider();
|
|
942
|
+
if (!wallet) {
|
|
943
|
+
throw new Error("Wallet not connected");
|
|
944
|
+
}
|
|
945
|
+
try {
|
|
946
|
+
await ensureNetwork(wallet, request.network, true);
|
|
947
|
+
} catch (networkError) {
|
|
948
|
+
const errorMessage = networkError instanceof Error ? networkError.message : "Network switch failed";
|
|
949
|
+
throw new Error(
|
|
950
|
+
`Failed to switch network: ${errorMessage}. Please ensure you're on ${request.network}`
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
const payment = await processPayment(request, wallet);
|
|
954
|
+
setTxHash(payment.transactionHash);
|
|
955
|
+
setTimeout(() => {
|
|
956
|
+
onComplete(payment);
|
|
957
|
+
}, 2e3);
|
|
958
|
+
} catch (err) {
|
|
959
|
+
let errorMessage = "Payment failed";
|
|
960
|
+
if (err instanceof Error) {
|
|
961
|
+
errorMessage = err.message;
|
|
962
|
+
if (err.message.includes("user rejected") || err.message.includes("User denied")) {
|
|
963
|
+
errorMessage = "Transaction was rejected. Please try again.";
|
|
964
|
+
} else if (err.message.includes("insufficient funds") || err.message.includes("insufficient balance")) {
|
|
965
|
+
errorMessage = "Insufficient funds. Please ensure you have enough MNT in your wallet.";
|
|
966
|
+
} else if (err.message.includes("network")) {
|
|
967
|
+
errorMessage = err.message;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
setError(errorMessage);
|
|
971
|
+
setIsProcessing(false);
|
|
972
|
+
}
|
|
973
|
+
};
|
|
974
|
+
if (!request || !request.amount || !request.recipient || !request.network) {
|
|
975
|
+
console.error("Invalid payment request:", request);
|
|
976
|
+
if (isOpen) {
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
978
|
+
"div",
|
|
979
|
+
{
|
|
980
|
+
style: {
|
|
981
|
+
position: "fixed",
|
|
982
|
+
inset: 0,
|
|
983
|
+
zIndex: 9999,
|
|
984
|
+
display: "flex",
|
|
985
|
+
alignItems: "center",
|
|
986
|
+
justifyContent: "center",
|
|
987
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
988
|
+
backdropFilter: "blur(4px)",
|
|
989
|
+
padding: "1rem"
|
|
990
|
+
},
|
|
991
|
+
onClick: (e) => e.target === e.currentTarget && onCancel(),
|
|
992
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
993
|
+
"div",
|
|
994
|
+
{
|
|
995
|
+
style: {
|
|
996
|
+
width: "100%",
|
|
997
|
+
maxWidth: "28rem",
|
|
998
|
+
borderRadius: "0.75rem",
|
|
999
|
+
border: "1px solid rgba(239, 68, 68, 0.5)",
|
|
1000
|
+
background: "rgba(24, 24, 27, 0.95)",
|
|
1001
|
+
padding: "1.5rem",
|
|
1002
|
+
color: "#fafafa"
|
|
1003
|
+
},
|
|
1004
|
+
children: [
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { style: { margin: "0 0 1rem 0", color: "rgba(239, 68, 68, 0.9)" }, children: "Invalid Payment Request" }),
|
|
1006
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { style: { margin: "0 0 1rem 0", color: "rgba(250, 250, 250, 0.8)" }, children: "The payment request is missing required information. Please try again." }),
|
|
1007
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1008
|
+
"button",
|
|
1009
|
+
{
|
|
1010
|
+
onClick: onCancel,
|
|
1011
|
+
style: {
|
|
1012
|
+
width: "100%",
|
|
1013
|
+
padding: "0.75rem",
|
|
1014
|
+
borderRadius: "0.5rem",
|
|
1015
|
+
border: "1px solid rgba(255, 255, 255, 0.2)",
|
|
1016
|
+
background: "rgba(255, 255, 255, 0.1)",
|
|
1017
|
+
color: "#fafafa",
|
|
1018
|
+
cursor: "pointer"
|
|
1019
|
+
},
|
|
1020
|
+
children: "Close"
|
|
1021
|
+
}
|
|
1022
|
+
)
|
|
1023
|
+
]
|
|
1024
|
+
}
|
|
1025
|
+
)
|
|
1026
|
+
}
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
1029
|
+
return null;
|
|
1030
|
+
}
|
|
1031
|
+
if (!isOpen) return null;
|
|
1032
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1033
|
+
"div",
|
|
1034
|
+
{
|
|
1035
|
+
style: {
|
|
1036
|
+
position: "fixed",
|
|
1037
|
+
inset: 0,
|
|
1038
|
+
zIndex: 9999,
|
|
1039
|
+
display: "flex",
|
|
1040
|
+
alignItems: "center",
|
|
1041
|
+
justifyContent: "center",
|
|
1042
|
+
background: "rgba(0, 0, 0, 0.5)",
|
|
1043
|
+
backdropFilter: "blur(4px)",
|
|
1044
|
+
padding: "1rem"
|
|
1045
|
+
},
|
|
1046
|
+
onClick: (e) => e.target === e.currentTarget && onCancel(),
|
|
1047
|
+
children: [
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1049
|
+
"div",
|
|
1050
|
+
{
|
|
1051
|
+
style: {
|
|
1052
|
+
width: "100%",
|
|
1053
|
+
maxWidth: "28rem",
|
|
1054
|
+
borderRadius: "0.75rem",
|
|
1055
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1056
|
+
background: "rgba(24, 24, 27, 0.95)",
|
|
1057
|
+
padding: "1.5rem",
|
|
1058
|
+
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.3)",
|
|
1059
|
+
backdropFilter: "blur(16px)",
|
|
1060
|
+
color: "#fafafa",
|
|
1061
|
+
maxHeight: "90vh",
|
|
1062
|
+
overflowY: "auto"
|
|
1063
|
+
},
|
|
1064
|
+
children: [
|
|
1065
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1066
|
+
"div",
|
|
1067
|
+
{
|
|
1068
|
+
style: {
|
|
1069
|
+
display: "flex",
|
|
1070
|
+
alignItems: "center",
|
|
1071
|
+
justifyContent: "space-between",
|
|
1072
|
+
marginBottom: "1rem"
|
|
1073
|
+
},
|
|
1074
|
+
children: [
|
|
1075
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1076
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1077
|
+
"h2",
|
|
1078
|
+
{
|
|
1079
|
+
style: {
|
|
1080
|
+
margin: 0,
|
|
1081
|
+
fontSize: "1.25rem",
|
|
1082
|
+
fontWeight: 300,
|
|
1083
|
+
color: "#fafafa"
|
|
1084
|
+
},
|
|
1085
|
+
children: txHash ? "Payment Complete" : "Payment Required"
|
|
1086
|
+
}
|
|
1087
|
+
),
|
|
1088
|
+
simulation && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1089
|
+
"span",
|
|
1090
|
+
{
|
|
1091
|
+
style: {
|
|
1092
|
+
borderRadius: "9999px",
|
|
1093
|
+
border: "1px solid rgba(234, 179, 8, 0.4)",
|
|
1094
|
+
background: "rgba(234, 179, 8, 0.2)",
|
|
1095
|
+
padding: "0.125rem 0.5rem",
|
|
1096
|
+
fontFamily: "monospace",
|
|
1097
|
+
fontSize: "0.75rem",
|
|
1098
|
+
color: "rgba(234, 179, 8, 1)"
|
|
1099
|
+
},
|
|
1100
|
+
children: "SIMULATION"
|
|
1101
|
+
}
|
|
1102
|
+
)
|
|
1103
|
+
] }),
|
|
1104
|
+
!isProcessing && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1105
|
+
"button",
|
|
1106
|
+
{
|
|
1107
|
+
onClick: onCancel,
|
|
1108
|
+
style: {
|
|
1109
|
+
background: "none",
|
|
1110
|
+
border: "none",
|
|
1111
|
+
fontSize: "1.5rem",
|
|
1112
|
+
cursor: "pointer",
|
|
1113
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1114
|
+
lineHeight: 1,
|
|
1115
|
+
padding: 0,
|
|
1116
|
+
display: "flex",
|
|
1117
|
+
alignItems: "center",
|
|
1118
|
+
justifyContent: "center"
|
|
1119
|
+
},
|
|
1120
|
+
"aria-label": "Close",
|
|
1121
|
+
children: "\xD7"
|
|
1122
|
+
}
|
|
1123
|
+
)
|
|
1124
|
+
]
|
|
1125
|
+
}
|
|
1126
|
+
),
|
|
1127
|
+
txHash ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
1128
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1129
|
+
"div",
|
|
1130
|
+
{
|
|
1131
|
+
style: {
|
|
1132
|
+
display: "flex",
|
|
1133
|
+
alignItems: "center",
|
|
1134
|
+
justifyContent: "center",
|
|
1135
|
+
padding: "0.5rem 0"
|
|
1136
|
+
},
|
|
1137
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1138
|
+
"div",
|
|
1139
|
+
{
|
|
1140
|
+
style: {
|
|
1141
|
+
borderRadius: "50%",
|
|
1142
|
+
background: "rgba(34, 197, 94, 0.2)",
|
|
1143
|
+
padding: "0.75rem"
|
|
1144
|
+
},
|
|
1145
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1146
|
+
"svg",
|
|
1147
|
+
{
|
|
1148
|
+
width: "32",
|
|
1149
|
+
height: "32",
|
|
1150
|
+
viewBox: "0 0 24 24",
|
|
1151
|
+
fill: "none",
|
|
1152
|
+
stroke: "rgba(34, 197, 94, 1)",
|
|
1153
|
+
strokeWidth: "2",
|
|
1154
|
+
strokeLinecap: "round",
|
|
1155
|
+
strokeLinejoin: "round",
|
|
1156
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M20 6L9 17l-5-5" })
|
|
1157
|
+
}
|
|
1158
|
+
)
|
|
1159
|
+
}
|
|
1160
|
+
)
|
|
1161
|
+
}
|
|
1162
|
+
),
|
|
1163
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginBottom: "1rem", display: "flex", flexDirection: "column", gap: "0.75rem" }, children: [
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1165
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1166
|
+
"p",
|
|
1167
|
+
{
|
|
1168
|
+
style: {
|
|
1169
|
+
marginBottom: "0.5rem",
|
|
1170
|
+
fontFamily: "monospace",
|
|
1171
|
+
fontSize: "0.75rem",
|
|
1172
|
+
color: "rgba(250, 250, 250, 0.6)"
|
|
1173
|
+
},
|
|
1174
|
+
children: "Transaction Hash"
|
|
1175
|
+
}
|
|
1176
|
+
),
|
|
1177
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1178
|
+
"div",
|
|
1179
|
+
{
|
|
1180
|
+
style: {
|
|
1181
|
+
display: "flex",
|
|
1182
|
+
alignItems: "center",
|
|
1183
|
+
gap: "0.5rem",
|
|
1184
|
+
borderRadius: "0.5rem",
|
|
1185
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1186
|
+
background: "rgba(0, 0, 0, 0.3)",
|
|
1187
|
+
padding: "0.5rem 0.75rem",
|
|
1188
|
+
overflow: "hidden"
|
|
1189
|
+
},
|
|
1190
|
+
children: [
|
|
1191
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1192
|
+
"code",
|
|
1193
|
+
{
|
|
1194
|
+
style: {
|
|
1195
|
+
minWidth: 0,
|
|
1196
|
+
flex: 1,
|
|
1197
|
+
overflow: "hidden",
|
|
1198
|
+
textOverflow: "ellipsis",
|
|
1199
|
+
whiteSpace: "nowrap",
|
|
1200
|
+
fontFamily: "monospace",
|
|
1201
|
+
fontSize: "0.875rem",
|
|
1202
|
+
color: "#fafafa"
|
|
1203
|
+
},
|
|
1204
|
+
children: txHash
|
|
1205
|
+
}
|
|
1206
|
+
),
|
|
1207
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1208
|
+
"div",
|
|
1209
|
+
{
|
|
1210
|
+
style: {
|
|
1211
|
+
display: "flex",
|
|
1212
|
+
alignItems: "center",
|
|
1213
|
+
gap: "0.375rem",
|
|
1214
|
+
flexShrink: 0
|
|
1215
|
+
},
|
|
1216
|
+
children: [
|
|
1217
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1218
|
+
"button",
|
|
1219
|
+
{
|
|
1220
|
+
onClick: () => handleCopy(txHash),
|
|
1221
|
+
style: {
|
|
1222
|
+
display: "flex",
|
|
1223
|
+
alignItems: "center",
|
|
1224
|
+
gap: "0.375rem",
|
|
1225
|
+
borderRadius: "0.375rem",
|
|
1226
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1227
|
+
background: "rgba(255, 255, 255, 0.1)",
|
|
1228
|
+
padding: "0.25rem 0.625rem",
|
|
1229
|
+
fontFamily: "monospace",
|
|
1230
|
+
fontSize: "0.75rem",
|
|
1231
|
+
color: "#fafafa",
|
|
1232
|
+
cursor: "pointer",
|
|
1233
|
+
transition: "background 0.2s"
|
|
1234
|
+
},
|
|
1235
|
+
onMouseEnter: (e) => e.currentTarget.style.background = "rgba(255, 255, 255, 0.2)",
|
|
1236
|
+
onMouseLeave: (e) => e.currentTarget.style.background = "rgba(255, 255, 255, 0.1)",
|
|
1237
|
+
title: "Copy transaction hash",
|
|
1238
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1239
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1240
|
+
"svg",
|
|
1241
|
+
{
|
|
1242
|
+
width: "14",
|
|
1243
|
+
height: "14",
|
|
1244
|
+
viewBox: "0 0 24 24",
|
|
1245
|
+
fill: "none",
|
|
1246
|
+
stroke: "currentColor",
|
|
1247
|
+
strokeWidth: "2",
|
|
1248
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M20 6L9 17l-5-5" })
|
|
1249
|
+
}
|
|
1250
|
+
),
|
|
1251
|
+
"Copied"
|
|
1252
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1254
|
+
"svg",
|
|
1255
|
+
{
|
|
1256
|
+
width: "14",
|
|
1257
|
+
height: "14",
|
|
1258
|
+
viewBox: "0 0 24 24",
|
|
1259
|
+
fill: "none",
|
|
1260
|
+
stroke: "currentColor",
|
|
1261
|
+
strokeWidth: "2",
|
|
1262
|
+
children: [
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
1264
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" })
|
|
1265
|
+
]
|
|
1266
|
+
}
|
|
1267
|
+
),
|
|
1268
|
+
"Copy"
|
|
1269
|
+
] })
|
|
1270
|
+
}
|
|
1271
|
+
),
|
|
1272
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1273
|
+
"a",
|
|
1274
|
+
{
|
|
1275
|
+
href: getExplorerUrl(txHash, request.network),
|
|
1276
|
+
target: "_blank",
|
|
1277
|
+
rel: "noopener noreferrer",
|
|
1278
|
+
style: {
|
|
1279
|
+
display: "flex",
|
|
1280
|
+
alignItems: "center",
|
|
1281
|
+
justifyContent: "center",
|
|
1282
|
+
borderRadius: "0.375rem",
|
|
1283
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1284
|
+
background: "rgba(255, 255, 255, 0.1)",
|
|
1285
|
+
padding: "0.375rem",
|
|
1286
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1287
|
+
cursor: "pointer",
|
|
1288
|
+
transition: "all 0.2s",
|
|
1289
|
+
textDecoration: "none"
|
|
1290
|
+
},
|
|
1291
|
+
onMouseEnter: (e) => {
|
|
1292
|
+
e.currentTarget.style.background = "rgba(255, 255, 255, 0.2)";
|
|
1293
|
+
e.currentTarget.style.color = "#fafafa";
|
|
1294
|
+
},
|
|
1295
|
+
onMouseLeave: (e) => {
|
|
1296
|
+
e.currentTarget.style.background = "rgba(255, 255, 255, 0.1)";
|
|
1297
|
+
e.currentTarget.style.color = "rgba(250, 250, 250, 0.6)";
|
|
1298
|
+
},
|
|
1299
|
+
title: "View on explorer",
|
|
1300
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1301
|
+
"svg",
|
|
1302
|
+
{
|
|
1303
|
+
width: "14",
|
|
1304
|
+
height: "14",
|
|
1305
|
+
viewBox: "0 0 24 24",
|
|
1306
|
+
fill: "none",
|
|
1307
|
+
stroke: "currentColor",
|
|
1308
|
+
strokeWidth: "2",
|
|
1309
|
+
children: [
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6" }),
|
|
1311
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M15 3h6v6" }),
|
|
1312
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M10 14L21 3" })
|
|
1313
|
+
]
|
|
1314
|
+
}
|
|
1315
|
+
)
|
|
1316
|
+
}
|
|
1317
|
+
)
|
|
1318
|
+
]
|
|
1319
|
+
}
|
|
1320
|
+
)
|
|
1321
|
+
]
|
|
1322
|
+
}
|
|
1323
|
+
)
|
|
1324
|
+
] }),
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1326
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1327
|
+
"p",
|
|
1328
|
+
{
|
|
1329
|
+
style: {
|
|
1330
|
+
marginBottom: "0.5rem",
|
|
1331
|
+
fontFamily: "monospace",
|
|
1332
|
+
fontSize: "0.75rem",
|
|
1333
|
+
color: "rgba(250, 250, 250, 0.6)"
|
|
1334
|
+
},
|
|
1335
|
+
children: "Amount Paid"
|
|
1336
|
+
}
|
|
1337
|
+
),
|
|
1338
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1339
|
+
"p",
|
|
1340
|
+
{
|
|
1341
|
+
style: {
|
|
1342
|
+
fontFamily: "sans-serif",
|
|
1343
|
+
fontSize: "1rem",
|
|
1344
|
+
color: "#fafafa",
|
|
1345
|
+
margin: 0
|
|
1346
|
+
},
|
|
1347
|
+
children: [
|
|
1348
|
+
request.amount,
|
|
1349
|
+
" ",
|
|
1350
|
+
request.token
|
|
1351
|
+
]
|
|
1352
|
+
}
|
|
1353
|
+
)
|
|
1354
|
+
] })
|
|
1355
|
+
] }),
|
|
1356
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1357
|
+
"button",
|
|
1358
|
+
{
|
|
1359
|
+
onClick: onCancel,
|
|
1360
|
+
style: {
|
|
1361
|
+
width: "100%",
|
|
1362
|
+
borderRadius: "0.5rem",
|
|
1363
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1364
|
+
background: "rgba(255, 255, 255, 0.15)",
|
|
1365
|
+
padding: "0.625rem 1rem",
|
|
1366
|
+
fontFamily: "sans-serif",
|
|
1367
|
+
fontSize: "0.875rem",
|
|
1368
|
+
color: "#fafafa",
|
|
1369
|
+
cursor: "pointer",
|
|
1370
|
+
transition: "background 0.2s"
|
|
1371
|
+
},
|
|
1372
|
+
onMouseEnter: (e) => e.currentTarget.style.background = "rgba(255, 255, 255, 0.2)",
|
|
1373
|
+
onMouseLeave: (e) => e.currentTarget.style.background = "rgba(255, 255, 255, 0.15)",
|
|
1374
|
+
children: "Done"
|
|
1375
|
+
}
|
|
1376
|
+
)
|
|
1377
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
1378
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginBottom: "1.5rem", display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
1379
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1380
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1381
|
+
"p",
|
|
1382
|
+
{
|
|
1383
|
+
style: {
|
|
1384
|
+
marginBottom: "0.5rem",
|
|
1385
|
+
fontFamily: "monospace",
|
|
1386
|
+
fontSize: "0.75rem",
|
|
1387
|
+
color: "rgba(250, 250, 250, 0.6)"
|
|
1388
|
+
},
|
|
1389
|
+
children: "Description"
|
|
1390
|
+
}
|
|
1391
|
+
),
|
|
1392
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1393
|
+
"p",
|
|
1394
|
+
{
|
|
1395
|
+
style: {
|
|
1396
|
+
fontFamily: "sans-serif",
|
|
1397
|
+
fontSize: "0.875rem",
|
|
1398
|
+
color: "#fafafa",
|
|
1399
|
+
margin: 0
|
|
1400
|
+
},
|
|
1401
|
+
children: description
|
|
1402
|
+
}
|
|
1403
|
+
)
|
|
1404
|
+
] }),
|
|
1405
|
+
endpoint && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
1406
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1407
|
+
"p",
|
|
1408
|
+
{
|
|
1409
|
+
style: {
|
|
1410
|
+
marginBottom: "0.5rem",
|
|
1411
|
+
fontFamily: "monospace",
|
|
1412
|
+
fontSize: "0.75rem",
|
|
1413
|
+
color: "rgba(250, 250, 250, 0.6)"
|
|
1414
|
+
},
|
|
1415
|
+
children: "Endpoint"
|
|
1416
|
+
}
|
|
1417
|
+
),
|
|
1418
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1419
|
+
"code",
|
|
1420
|
+
{
|
|
1421
|
+
style: {
|
|
1422
|
+
fontFamily: "monospace",
|
|
1423
|
+
fontSize: "0.75rem",
|
|
1424
|
+
color: "rgba(250, 250, 250, 0.8)",
|
|
1425
|
+
wordBreak: "break-all"
|
|
1426
|
+
},
|
|
1427
|
+
children: endpoint
|
|
1428
|
+
}
|
|
1429
|
+
)
|
|
1430
|
+
] }),
|
|
1431
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1432
|
+
"div",
|
|
1433
|
+
{
|
|
1434
|
+
style: {
|
|
1435
|
+
borderRadius: "0.5rem",
|
|
1436
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1437
|
+
background: "rgba(255, 255, 255, 0.05)",
|
|
1438
|
+
padding: "1rem"
|
|
1439
|
+
},
|
|
1440
|
+
children: [
|
|
1441
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1442
|
+
"div",
|
|
1443
|
+
{
|
|
1444
|
+
style: {
|
|
1445
|
+
marginBottom: "0.75rem",
|
|
1446
|
+
display: "flex",
|
|
1447
|
+
alignItems: "center",
|
|
1448
|
+
justifyContent: "space-between"
|
|
1449
|
+
},
|
|
1450
|
+
children: [
|
|
1451
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1452
|
+
"p",
|
|
1453
|
+
{
|
|
1454
|
+
style: {
|
|
1455
|
+
fontFamily: "monospace",
|
|
1456
|
+
fontSize: "0.75rem",
|
|
1457
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1458
|
+
margin: 0
|
|
1459
|
+
},
|
|
1460
|
+
children: "Amount"
|
|
1461
|
+
}
|
|
1462
|
+
),
|
|
1463
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1464
|
+
"p",
|
|
1465
|
+
{
|
|
1466
|
+
style: {
|
|
1467
|
+
fontFamily: "sans-serif",
|
|
1468
|
+
fontSize: "1.5rem",
|
|
1469
|
+
fontWeight: 300,
|
|
1470
|
+
color: "#fafafa",
|
|
1471
|
+
margin: 0
|
|
1472
|
+
},
|
|
1473
|
+
children: [
|
|
1474
|
+
request.amount,
|
|
1475
|
+
" ",
|
|
1476
|
+
request.token
|
|
1477
|
+
]
|
|
1478
|
+
}
|
|
1479
|
+
)
|
|
1480
|
+
]
|
|
1481
|
+
}
|
|
1482
|
+
),
|
|
1483
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1484
|
+
"div",
|
|
1485
|
+
{
|
|
1486
|
+
style: {
|
|
1487
|
+
display: "flex",
|
|
1488
|
+
flexDirection: "column",
|
|
1489
|
+
gap: "0.5rem",
|
|
1490
|
+
borderTop: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1491
|
+
paddingTop: "0.75rem"
|
|
1492
|
+
},
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1495
|
+
"div",
|
|
1496
|
+
{
|
|
1497
|
+
style: {
|
|
1498
|
+
display: "flex",
|
|
1499
|
+
alignItems: "center",
|
|
1500
|
+
justifyContent: "space-between"
|
|
1501
|
+
},
|
|
1502
|
+
children: [
|
|
1503
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1504
|
+
"p",
|
|
1505
|
+
{
|
|
1506
|
+
style: {
|
|
1507
|
+
fontFamily: "monospace",
|
|
1508
|
+
fontSize: "0.75rem",
|
|
1509
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1510
|
+
margin: 0
|
|
1511
|
+
},
|
|
1512
|
+
children: "Network"
|
|
1513
|
+
}
|
|
1514
|
+
),
|
|
1515
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1516
|
+
"p",
|
|
1517
|
+
{
|
|
1518
|
+
style: {
|
|
1519
|
+
fontFamily: "monospace",
|
|
1520
|
+
fontSize: "0.75rem",
|
|
1521
|
+
color: "#fafafa",
|
|
1522
|
+
margin: 0
|
|
1523
|
+
},
|
|
1524
|
+
children: request.network
|
|
1525
|
+
}
|
|
1526
|
+
)
|
|
1527
|
+
]
|
|
1528
|
+
}
|
|
1529
|
+
),
|
|
1530
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1531
|
+
"div",
|
|
1532
|
+
{
|
|
1533
|
+
style: {
|
|
1534
|
+
display: "flex",
|
|
1535
|
+
alignItems: "center",
|
|
1536
|
+
justifyContent: "space-between",
|
|
1537
|
+
gap: "0.5rem"
|
|
1538
|
+
},
|
|
1539
|
+
children: [
|
|
1540
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1541
|
+
"p",
|
|
1542
|
+
{
|
|
1543
|
+
style: {
|
|
1544
|
+
fontFamily: "monospace",
|
|
1545
|
+
fontSize: "0.75rem",
|
|
1546
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1547
|
+
margin: 0
|
|
1548
|
+
},
|
|
1549
|
+
children: "Recipient"
|
|
1550
|
+
}
|
|
1551
|
+
),
|
|
1552
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1554
|
+
"code",
|
|
1555
|
+
{
|
|
1556
|
+
style: {
|
|
1557
|
+
fontFamily: "monospace",
|
|
1558
|
+
fontSize: "0.75rem",
|
|
1559
|
+
color: "#fafafa"
|
|
1560
|
+
},
|
|
1561
|
+
children: formatAddress2(request.recipient)
|
|
1562
|
+
}
|
|
1563
|
+
),
|
|
1564
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1565
|
+
"button",
|
|
1566
|
+
{
|
|
1567
|
+
onClick: () => handleCopy(request.recipient),
|
|
1568
|
+
style: {
|
|
1569
|
+
background: "none",
|
|
1570
|
+
border: "none",
|
|
1571
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1572
|
+
cursor: "pointer",
|
|
1573
|
+
padding: 0,
|
|
1574
|
+
display: "flex",
|
|
1575
|
+
alignItems: "center",
|
|
1576
|
+
justifyContent: "center",
|
|
1577
|
+
transition: "color 0.2s"
|
|
1578
|
+
},
|
|
1579
|
+
onMouseEnter: (e) => e.currentTarget.style.color = "#fafafa",
|
|
1580
|
+
onMouseLeave: (e) => e.currentTarget.style.color = "rgba(250, 250, 250, 0.6)",
|
|
1581
|
+
title: "Copy address",
|
|
1582
|
+
children: copied ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1583
|
+
"svg",
|
|
1584
|
+
{
|
|
1585
|
+
width: "14",
|
|
1586
|
+
height: "14",
|
|
1587
|
+
viewBox: "0 0 24 24",
|
|
1588
|
+
fill: "none",
|
|
1589
|
+
stroke: "rgba(34, 197, 94, 1)",
|
|
1590
|
+
strokeWidth: "2",
|
|
1591
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M20 6L9 17l-5-5" })
|
|
1592
|
+
}
|
|
1593
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1594
|
+
"svg",
|
|
1595
|
+
{
|
|
1596
|
+
width: "14",
|
|
1597
|
+
height: "14",
|
|
1598
|
+
viewBox: "0 0 24 24",
|
|
1599
|
+
fill: "none",
|
|
1600
|
+
stroke: "currentColor",
|
|
1601
|
+
strokeWidth: "2",
|
|
1602
|
+
children: [
|
|
1603
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }),
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1" })
|
|
1605
|
+
]
|
|
1606
|
+
}
|
|
1607
|
+
)
|
|
1608
|
+
}
|
|
1609
|
+
)
|
|
1610
|
+
] })
|
|
1611
|
+
]
|
|
1612
|
+
}
|
|
1613
|
+
),
|
|
1614
|
+
walletAddress && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1615
|
+
"div",
|
|
1616
|
+
{
|
|
1617
|
+
style: {
|
|
1618
|
+
display: "flex",
|
|
1619
|
+
alignItems: "center",
|
|
1620
|
+
justifyContent: "space-between",
|
|
1621
|
+
gap: "0.5rem"
|
|
1622
|
+
},
|
|
1623
|
+
children: [
|
|
1624
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1625
|
+
"p",
|
|
1626
|
+
{
|
|
1627
|
+
style: {
|
|
1628
|
+
fontFamily: "monospace",
|
|
1629
|
+
fontSize: "0.75rem",
|
|
1630
|
+
color: "rgba(250, 250, 250, 0.6)",
|
|
1631
|
+
margin: 0
|
|
1632
|
+
},
|
|
1633
|
+
children: "From"
|
|
1634
|
+
}
|
|
1635
|
+
),
|
|
1636
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
|
|
1637
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1638
|
+
"svg",
|
|
1639
|
+
{
|
|
1640
|
+
width: "14",
|
|
1641
|
+
height: "14",
|
|
1642
|
+
viewBox: "0 0 24 24",
|
|
1643
|
+
fill: "none",
|
|
1644
|
+
stroke: "rgba(250, 250, 250, 0.6)",
|
|
1645
|
+
strokeWidth: "2",
|
|
1646
|
+
children: [
|
|
1647
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M21 12V7H5a2 2 0 01 0-4h14v4" }),
|
|
1648
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M3 5v14a2 2 0 002 2h16v-5" }),
|
|
1649
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M5 21a2 2 0 110-4h14" })
|
|
1650
|
+
]
|
|
1651
|
+
}
|
|
1652
|
+
),
|
|
1653
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1654
|
+
"code",
|
|
1655
|
+
{
|
|
1656
|
+
style: {
|
|
1657
|
+
fontFamily: "monospace",
|
|
1658
|
+
fontSize: "0.75rem",
|
|
1659
|
+
color: "#fafafa"
|
|
1660
|
+
},
|
|
1661
|
+
children: formatAddress2(walletAddress)
|
|
1662
|
+
}
|
|
1663
|
+
)
|
|
1664
|
+
] })
|
|
1665
|
+
]
|
|
1666
|
+
}
|
|
1667
|
+
)
|
|
1668
|
+
]
|
|
1669
|
+
}
|
|
1670
|
+
)
|
|
1671
|
+
]
|
|
1672
|
+
}
|
|
1673
|
+
)
|
|
1674
|
+
] }),
|
|
1675
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1676
|
+
"div",
|
|
1677
|
+
{
|
|
1678
|
+
style: {
|
|
1679
|
+
marginBottom: "1rem",
|
|
1680
|
+
display: "flex",
|
|
1681
|
+
alignItems: "start",
|
|
1682
|
+
gap: "0.75rem",
|
|
1683
|
+
borderRadius: "0.5rem",
|
|
1684
|
+
border: "1px solid rgba(239, 68, 68, 0.3)",
|
|
1685
|
+
background: "rgba(239, 68, 68, 0.1)",
|
|
1686
|
+
padding: "0.75rem"
|
|
1687
|
+
},
|
|
1688
|
+
children: [
|
|
1689
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1690
|
+
"svg",
|
|
1691
|
+
{
|
|
1692
|
+
width: "20",
|
|
1693
|
+
height: "20",
|
|
1694
|
+
viewBox: "0 0 24 24",
|
|
1695
|
+
fill: "none",
|
|
1696
|
+
stroke: "rgba(239, 68, 68, 1)",
|
|
1697
|
+
strokeWidth: "2",
|
|
1698
|
+
style: { flexShrink: 0, marginTop: "0.125rem" },
|
|
1699
|
+
children: [
|
|
1700
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
1701
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 8v4" }),
|
|
1702
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 16h.01" })
|
|
1703
|
+
]
|
|
1704
|
+
}
|
|
1705
|
+
),
|
|
1706
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1707
|
+
"p",
|
|
1708
|
+
{
|
|
1709
|
+
style: {
|
|
1710
|
+
flex: 1,
|
|
1711
|
+
fontFamily: "monospace",
|
|
1712
|
+
fontSize: "0.75rem",
|
|
1713
|
+
color: "rgba(239, 68, 68, 1)",
|
|
1714
|
+
wordBreak: "break-word",
|
|
1715
|
+
margin: 0
|
|
1716
|
+
},
|
|
1717
|
+
children: error
|
|
1718
|
+
}
|
|
1719
|
+
)
|
|
1720
|
+
]
|
|
1721
|
+
}
|
|
1722
|
+
),
|
|
1723
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "flex", gap: "0.75rem" }, children: [
|
|
1724
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1725
|
+
"button",
|
|
1726
|
+
{
|
|
1727
|
+
onClick: onCancel,
|
|
1728
|
+
disabled: isProcessing,
|
|
1729
|
+
style: {
|
|
1730
|
+
flex: 1,
|
|
1731
|
+
borderRadius: "0.5rem",
|
|
1732
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1733
|
+
background: "rgba(255, 255, 255, 0.05)",
|
|
1734
|
+
padding: "0.625rem 1rem",
|
|
1735
|
+
fontFamily: "sans-serif",
|
|
1736
|
+
fontSize: "0.875rem",
|
|
1737
|
+
color: "rgba(250, 250, 250, 0.8)",
|
|
1738
|
+
cursor: isProcessing ? "not-allowed" : "pointer",
|
|
1739
|
+
opacity: isProcessing ? 0.5 : 1,
|
|
1740
|
+
transition: "background 0.2s"
|
|
1741
|
+
},
|
|
1742
|
+
onMouseEnter: (e) => {
|
|
1743
|
+
if (!isProcessing) e.currentTarget.style.background = "rgba(255, 255, 255, 0.1)";
|
|
1744
|
+
},
|
|
1745
|
+
onMouseLeave: (e) => {
|
|
1746
|
+
if (!isProcessing) e.currentTarget.style.background = "rgba(255, 255, 255, 0.05)";
|
|
1747
|
+
},
|
|
1748
|
+
children: "Cancel"
|
|
1749
|
+
}
|
|
1750
|
+
),
|
|
1751
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1752
|
+
"button",
|
|
1753
|
+
{
|
|
1754
|
+
onClick: walletAddress ? handlePayment : handleConnect,
|
|
1755
|
+
disabled: isProcessing || isConnecting,
|
|
1756
|
+
style: {
|
|
1757
|
+
flex: 1,
|
|
1758
|
+
borderRadius: "0.5rem",
|
|
1759
|
+
border: "1px solid rgba(255, 255, 255, 0.1)",
|
|
1760
|
+
background: "rgba(255, 255, 255, 0.15)",
|
|
1761
|
+
padding: "0.625rem 1rem",
|
|
1762
|
+
fontFamily: "sans-serif",
|
|
1763
|
+
fontSize: "0.875rem",
|
|
1764
|
+
color: "#fafafa",
|
|
1765
|
+
cursor: isProcessing || isConnecting ? "not-allowed" : "pointer",
|
|
1766
|
+
opacity: isProcessing || isConnecting ? 0.5 : 1,
|
|
1767
|
+
transition: "background 0.2s"
|
|
1768
|
+
},
|
|
1769
|
+
onMouseEnter: (e) => {
|
|
1770
|
+
if (!isProcessing && !isConnecting)
|
|
1771
|
+
e.currentTarget.style.background = "rgba(255, 255, 255, 0.2)";
|
|
1772
|
+
},
|
|
1773
|
+
onMouseLeave: (e) => {
|
|
1774
|
+
if (!isProcessing && !isConnecting)
|
|
1775
|
+
e.currentTarget.style.background = "rgba(255, 255, 255, 0.15)";
|
|
1776
|
+
},
|
|
1777
|
+
children: isProcessing ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1778
|
+
"span",
|
|
1779
|
+
{
|
|
1780
|
+
style: {
|
|
1781
|
+
display: "flex",
|
|
1782
|
+
alignItems: "center",
|
|
1783
|
+
justifyContent: "center",
|
|
1784
|
+
gap: "0.5rem"
|
|
1785
|
+
},
|
|
1786
|
+
children: [
|
|
1787
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1788
|
+
"svg",
|
|
1789
|
+
{
|
|
1790
|
+
width: "16",
|
|
1791
|
+
height: "16",
|
|
1792
|
+
viewBox: "0 0 24 24",
|
|
1793
|
+
fill: "none",
|
|
1794
|
+
stroke: "currentColor",
|
|
1795
|
+
strokeWidth: "2",
|
|
1796
|
+
style: {
|
|
1797
|
+
animation: "spin 1s linear infinite"
|
|
1798
|
+
},
|
|
1799
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M21 12a9 9 0 11-6.219-8.56" })
|
|
1800
|
+
}
|
|
1801
|
+
),
|
|
1802
|
+
simulation ? "Simulating..." : "Processing..."
|
|
1803
|
+
]
|
|
1804
|
+
}
|
|
1805
|
+
) : isConnecting ? "Connecting..." : !walletAddress ? "Connect Wallet" : simulation ? `Simulate ${request.amount} ${request.token}` : `Pay ${request.amount} ${request.token}`
|
|
1806
|
+
}
|
|
1807
|
+
)
|
|
1808
|
+
] })
|
|
1809
|
+
] })
|
|
1810
|
+
]
|
|
1811
|
+
}
|
|
1812
|
+
),
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: `
|
|
1814
|
+
@keyframes spin {
|
|
1815
|
+
to { transform: rotate(360deg); }
|
|
1816
|
+
}
|
|
1817
|
+
` })
|
|
1818
|
+
]
|
|
1819
|
+
}
|
|
1820
|
+
);
|
|
1821
|
+
}
|
|
654
1822
|
// Annotate the CommonJS export names for ESM import in node:
|
|
655
1823
|
0 && (module.exports = {
|
|
1824
|
+
EnhancedPaymentModal,
|
|
656
1825
|
PaymentModal
|
|
657
1826
|
});
|
|
658
1827
|
//# sourceMappingURL=react.cjs.map
|