@b3dotfun/sdk 0.0.17-alpha.1 → 0.0.17
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/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/cjs/anyspend/utils/chain.d.ts +2 -2
- package/dist/cjs/anyspend/utils/chain.js +6 -41
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/esm/anyspend/utils/chain.d.ts +2 -2
- package/dist/esm/anyspend/utils/chain.js +6 -41
- package/dist/types/anyspend/utils/chain.d.ts +2 -2
- package/package.json +1 -1
- package/src/anyspend/react/components/common/OrderDetails.tsx +0 -1
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +0 -1
- package/src/anyspend/utils/chain.ts +7 -52
|
@@ -488,7 +488,7 @@ exports.OrderDetails = (0, react_5.memo)(function OrderDetails({ isMainnet, mode
|
|
|
488
488
|
? (0, centerTruncate_1.default)(phantomWalletAddress, 6)
|
|
489
489
|
: (0, centerTruncate_1.default)(account?.address || "", 6)] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col items-center gap-2", children: [(0, jsx_runtime_1.jsxs)(react_1.ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [(0, jsx_runtime_1.jsx)("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] }) })) : (
|
|
490
490
|
// Default case - existing QR code flow
|
|
491
|
-
(0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress
|
|
491
|
+
(0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress), className: "max-w-[200px]" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_3.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_3.WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-center gap-1 text-sm", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary/30", children: "Time remaining:" }), (0, jsx_runtime_1.jsx)("div", { className: "text-as-primary", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : ((0, jsx_runtime_1.jsx)(react_timeago_1.default, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && ((0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })), (0, jsx_runtime_1.jsxs)("button", { className: "flex w-full items-center justify-center gap-2", onClick: handleBack, children: [(0, jsx_runtime_1.jsx)(lucide_react_1.RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
492
492
|
});
|
|
493
493
|
function TransactionDetails({ title, chainId, tx, isProcessing, delay, }) {
|
|
494
494
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative flex w-full flex-1 items-center justify-between gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex grow items-center gap-4", children: [(0, jsx_runtime_1.jsx)(react_4.motion.div, { className: "bg-b3-react-background relative h-10 w-10 rounded-full", children: isProcessing ? ((0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeInOut", delay }, className: "absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full bg-black/70 shadow-lg backdrop-blur-sm", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : ((0, jsx_runtime_1.jsx)(react_4.motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut", delay }, className: "bg-as-brand/70 absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border border-white/30 shadow-lg shadow-purple-500/30 backdrop-blur-sm", style: {
|
|
@@ -69,5 +69,5 @@ exports.TransferCryptoDetails = (0, react_3.memo)(function TransferCryptoDetails
|
|
|
69
69
|
transition: "stroke-dashoffset 1s linear",
|
|
70
70
|
} })] }), (0, jsx_runtime_1.jsx)("div", { className: "absolute inset-0 flex items-center justify-center", children: (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-[10px] font-semibold", children: formatTime(timeLeft) }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Amount" }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsx)(react_1.CopyToClipboard, { text: roundedUpSrcAmount || "", onCopy: () => {
|
|
71
71
|
sonner_1.toast.success("Amount copied to clipboard");
|
|
72
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.srcChain].logoUrl, alt: (0, anyspend_1.getChainName)(order.srcChain), className: (0, utils_1.cn)("h-6 rounded-full", order.srcChain === chains_1.b3.id && "h-5 rounded-none") }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: (0, anyspend_1.getChainName)(order.srcChain) })] }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary h-full w-full border-r", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress
|
|
72
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [(0, jsx_runtime_1.jsxs)("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), (0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[order.srcChain].logoUrl, alt: (0, anyspend_1.getChainName)(order.srcChain), className: (0, utils_1.cn)("h-6 rounded-full", order.srcChain === chains_1.b3.id && "h-5 rounded-none") }), (0, jsx_runtime_1.jsx)("span", { className: "text-as-primary text-sm font-semibold", children: (0, anyspend_1.getChainName)(order.srcChain) })] }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [(0, jsx_runtime_1.jsx)("div", { className: "border-as-border-primary h-full w-full border-r", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-center", children: (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [(0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeSVG, { value: (0, anyspend_1.getPaymentUrl)(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === anyspend_1.RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress), className: "bg-as-surface-secondary max-h-48 max-w-48" }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-brand/70 text-sm font-medium", children: "SCAN WITH" }), (0, jsx_runtime_1.jsxs)(react_1.TextLoop, { interval: 3, children: [(0, jsx_runtime_1.jsx)(react_2.WalletMetamask, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletPhantom, { className: "h-5 w-5", variant: "branded" }), (0, jsx_runtime_1.jsx)(react_2.WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full w-full flex-col gap-2 p-6", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-content-secondary text-sm font-medium", children: "Deposit address:" }), (0, jsx_runtime_1.jsxs)("div", { className: "flex h-full cursor-pointer flex-col items-stretch justify-between gap-4", onClick: handleCopyAddress, children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary break-all font-mono text-sm font-semibold leading-relaxed", children: order.globalAddress }), (0, jsx_runtime_1.jsx)("div", { className: "place-self-end", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Copy, { className: "group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" }) })] })] })] }), (0, jsx_runtime_1.jsx)(OrderDetailsCollapsible_1.OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-3", children: (0, jsx_runtime_1.jsx)(react_1.ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "w-full py-3", onClick: handleCopyAddress, children: "Copy deposit address" }) })] }));
|
|
73
73
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { components } from "../../anyspend/types/api";
|
|
2
1
|
import { Account, Chain, PublicClient, Transport, WalletClient } from "viem";
|
|
3
2
|
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
3
|
+
import { components } from "../../anyspend/types/api";
|
|
4
4
|
export declare const EVM_MAINNET: Record<number, IEVMChain>;
|
|
5
5
|
export declare const EVM_TESTNET: Record<number, IEVMChain>;
|
|
6
6
|
export declare const SOLANA_MAINNET: ISolanaChain;
|
|
@@ -18,7 +18,7 @@ export declare function isMainnet(chainId: number): boolean;
|
|
|
18
18
|
export declare function isTestnet(chainId: number): boolean;
|
|
19
19
|
export declare function getDefaultToken(chainId: number): components["schemas"]["Token"];
|
|
20
20
|
export declare function getChainName(chainId: number): string;
|
|
21
|
-
export declare function getPaymentUrl(address: string, amount: bigint, currency: string
|
|
21
|
+
export declare function getPaymentUrl(address: string, amount: bigint, currency: string): string;
|
|
22
22
|
export declare function getExplorerTxUrl(chainId: number, txHash: string): string;
|
|
23
23
|
export declare function getExplorerAddressUrl(chainId: number, address: string): string;
|
|
24
24
|
export declare function getMulticall3Address(chainId: number): string;
|
|
@@ -21,12 +21,12 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
|
21
21
|
exports.getMulticall3Address = getMulticall3Address;
|
|
22
22
|
exports.getNativeToken = getNativeToken;
|
|
23
23
|
exports.isEvmChain = isEvmChain;
|
|
24
|
-
const constants_1 = require("../../anyspend/constants");
|
|
25
24
|
const invariant_1 = __importDefault(require("invariant"));
|
|
26
25
|
const viem_1 = require("viem");
|
|
27
26
|
const chains_1 = require("viem/chains");
|
|
28
|
-
const
|
|
27
|
+
const constants_1 = require("../../anyspend/constants");
|
|
29
28
|
const token_1 = require("./token");
|
|
29
|
+
const chain_1 = require("../types/chain");
|
|
30
30
|
function getCustomEvmChain(chain, rpcUrl) {
|
|
31
31
|
return (0, viem_1.defineChain)({ ...chain, rpcUrls: { default: { http: [rpcUrl] } } });
|
|
32
32
|
}
|
|
@@ -260,46 +260,11 @@ function getChainName(chainId) {
|
|
|
260
260
|
(0, invariant_1.default)(exports.ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
|
|
261
261
|
return exports.EVM_CHAINS[chainId] ? exports.EVM_CHAINS[chainId].viem.name : "Solana";
|
|
262
262
|
}
|
|
263
|
-
function getPaymentUrl(address, amount, currency
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const chain = exports.ALL_CHAINS[chainId];
|
|
267
|
-
(0, invariant_1.default)(chain, `Chain ${chainId} is not supported`);
|
|
268
|
-
switch (chainType) {
|
|
269
|
-
case chain_1.ChainType.EVM: {
|
|
270
|
-
// For EVM chains, follow EIP-681 format
|
|
271
|
-
// Format: ethereum:[address]@[chainId]?value=[amount]&symbol=[symbol]
|
|
272
|
-
const params = new URLSearchParams();
|
|
273
|
-
// Add value for native token transfers
|
|
274
|
-
if (currency === chain.nativeToken.symbol) {
|
|
275
|
-
params.append("value", amount.toString());
|
|
276
|
-
}
|
|
277
|
-
// Add chain ID for non-Ethereum chains
|
|
278
|
-
const chainParam = chainId !== chains_1.mainnet.id ? `@${chainId}` : "";
|
|
279
|
-
// Add token info for non-native token transfers
|
|
280
|
-
if (currency !== chain.nativeToken.symbol) {
|
|
281
|
-
params.append("symbol", currency);
|
|
282
|
-
}
|
|
283
|
-
const queryString = params.toString();
|
|
284
|
-
return `ethereum:${address}${chainParam}${queryString ? `?${queryString}` : ""}`;
|
|
285
|
-
}
|
|
286
|
-
case chain_1.ChainType.SOLANA: {
|
|
287
|
-
// Solana URL format: solana:${address}?amount=${amount}&spl-token=${tokenAddress}
|
|
288
|
-
const params = new URLSearchParams();
|
|
289
|
-
// Add amount for native SOL transfers
|
|
290
|
-
if (currency === "SOL") {
|
|
291
|
-
params.append("amount", amount.toString());
|
|
292
|
-
}
|
|
293
|
-
// Add SPL token info for token transfers
|
|
294
|
-
if (currency !== "SOL") {
|
|
295
|
-
params.append("spl-token", currency); // currency here should be token address
|
|
296
|
-
}
|
|
297
|
-
return `solana:${address}?${params.toString()}`;
|
|
298
|
-
}
|
|
299
|
-
default:
|
|
300
|
-
// Fallback to just the address if chain type is unknown
|
|
301
|
-
return address;
|
|
263
|
+
function getPaymentUrl(address, amount, currency) {
|
|
264
|
+
if (currency === "ETH") {
|
|
265
|
+
return `ethereum:${address}?value=${amount.toString()}`;
|
|
302
266
|
}
|
|
267
|
+
return `ethereum:${address}`;
|
|
303
268
|
}
|
|
304
269
|
function getExplorerTxUrl(chainId, txHash) {
|
|
305
270
|
if (chainId === chains_1.b3.id) {
|
|
@@ -482,7 +482,7 @@ export const OrderDetails = memo(function OrderDetails({ isMainnet, mode = "moda
|
|
|
482
482
|
? centerTruncate(phantomWalletAddress, 6)
|
|
483
483
|
: centerTruncate(account?.address || "", 6)] })] }), _jsxs("div", { className: "flex w-full flex-col items-center gap-2", children: [_jsxs(ShinyButton, { accentColor: colorMode === "dark" ? "#ffffff" : "#000000", className: "flex w-5/6 items-center gap-2 sm:px-0", onClick: () => setShowQRCode(true), children: [_jsx("span", { className: "pl-4 text-lg md:text-sm", children: "Pay from a different wallet" }), _jsx(ChevronRight, { className: "h-4 w-4" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletWalletConnect, { className: "h-5 w-5", variant: "branded" }), _jsx("span", { className: "label-style text-as-primary/30 text-xs", children: "& more" })] })] })] }) })) : (
|
|
484
484
|
// Default case - existing QR code flow
|
|
485
|
-
_jsx(motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: _jsxs("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress
|
|
485
|
+
_jsx(motion.div, { initial: { opacity: 0, filter: "blur(10px)" }, animate: { opacity: 1, filter: "blur(0px)" }, transition: { duration: 0.5, ease: "easeInOut" }, className: "flex w-full items-center justify-evenly gap-4", children: _jsxs("div", { className: "mt-8 flex flex-col items-center rounded-lg bg-white p-6 pb-3", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress), className: "max-w-[200px]" }), _jsxs("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "label-style text-as-brand/70 text-sm", children: "Scan with" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }))] })) })), _jsxs("div", { className: "flex w-full items-center justify-center gap-1 text-sm", children: [_jsx("div", { className: "text-as-primary/30", children: "Time remaining:" }), _jsx("div", { className: "text-as-primary", children: depositEnoughAmount ? ("Received") : order.status === "expired" ? ("Expired") : (_jsx(TimeAgo, { date: new Date(order.expiredAt), live: true })) })] }), statusDisplay !== "processing" && (_jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })), _jsxs("button", { className: "flex w-full items-center justify-center gap-2", onClick: handleBack, children: [_jsx(RefreshCcw, { className: "ml-2 h-4 w-4" }), " Cancel and start over"] })] }));
|
|
486
486
|
});
|
|
487
487
|
function TransactionDetails({ title, chainId, tx, isProcessing, delay, }) {
|
|
488
488
|
return (_jsxs("div", { className: "relative flex w-full flex-1 items-center justify-between gap-4", children: [_jsxs("div", { className: "flex grow items-center gap-4", children: [_jsx(motion.div, { className: "bg-b3-react-background relative h-10 w-10 rounded-full", children: isProcessing ? (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeInOut", delay }, className: "absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full bg-black/70 shadow-lg backdrop-blur-sm", children: _jsx(Loader2, { className: "text-as-primary h-4 w-4 animate-spin" }) })) : (_jsx(motion.div, { initial: { opacity: 0, scale: 0.3 }, animate: { opacity: 1, scale: 1 }, transition: { duration: 0.5, ease: "easeOut", delay }, className: "bg-as-brand/70 absolute z-10 m-2 flex h-6 w-6 items-center justify-center rounded-full border border-white/30 shadow-lg shadow-purple-500/30 backdrop-blur-sm", style: {
|
|
@@ -66,5 +66,5 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({ order
|
|
|
66
66
|
transition: "stroke-dashoffset 1s linear",
|
|
67
67
|
} })] }), _jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: _jsx("span", { className: "text-as-primary text-[10px] font-semibold", children: formatTime(timeLeft) }) })] })] }), _jsxs("div", { className: "flex w-full flex-col gap-4", children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsxs("div", { className: "w-full", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Amount" }), _jsx("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: _jsx(CopyToClipboard, { text: roundedUpSrcAmount || "", onCopy: () => {
|
|
68
68
|
toast.success("Amount copied to clipboard");
|
|
69
|
-
}, children: _jsxs("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [_jsxs("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), _jsx(Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), _jsxs("div", { className: "w-full", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), _jsx("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("img", { src: ALL_CHAINS[order.srcChain].logoUrl, alt: getChainName(order.srcChain), className: cn("h-6 rounded-full", order.srcChain === b3.id && "h-5 rounded-none") }), _jsx("span", { className: "text-as-primary text-sm font-semibold", children: getChainName(order.srcChain) })] }) })] })] }), _jsxs("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [_jsx("div", { className: "border-as-border-primary h-full w-full border-r", children: _jsx("div", { className: "flex justify-center", children: _jsxs("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress
|
|
69
|
+
}, children: _jsxs("div", { className: "flex cursor-pointer items-center justify-between gap-2", children: [_jsxs("strong", { className: "text-as-primary font-semibold", children: [roundedUpSrcAmount, " ", srcToken.symbol] }), _jsx(Copy, { className: "text-as-primary/50 hover:text-as-primary h-4 w-4 transition-all duration-200" })] }) }) })] }), _jsxs("div", { className: "w-full", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Chain" }), _jsx("div", { className: "border-as-border-primary rounded-lg border p-2 shadow-sm", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("img", { src: ALL_CHAINS[order.srcChain].logoUrl, alt: getChainName(order.srcChain), className: cn("h-6 rounded-full", order.srcChain === b3.id && "h-5 rounded-none") }), _jsx("span", { className: "text-as-primary text-sm font-semibold", children: getChainName(order.srcChain) })] }) })] })] }), _jsxs("div", { className: "border-b3-react-border bg-as-surface-secondary grid h-[220px] grid-cols-2 overflow-hidden rounded-xl border", children: [_jsx("div", { className: "border-as-border-primary h-full w-full border-r", children: _jsx("div", { className: "flex justify-center", children: _jsxs("div", { className: "bg-as-surface-secondary flex flex-col items-center rounded-lg p-6", children: [_jsx(QRCodeSVG, { value: getPaymentUrl(order.globalAddress, BigInt(order.srcAmount), order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress), className: "bg-as-surface-secondary max-h-48 max-w-48" }), _jsxs("div", { className: "mt-3 flex items-center justify-center gap-2 text-sm", children: [_jsx("span", { className: "text-as-brand/70 text-sm font-medium", children: "SCAN WITH" }), _jsxs(TextLoop, { interval: 3, children: [_jsx(WalletMetamask, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletCoinbase, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletPhantom, { className: "h-5 w-5", variant: "branded" }), _jsx(WalletTrust, { className: "h-5 w-5", variant: "branded" })] })] })] }) }) }), _jsxs("div", { className: "flex h-full w-full flex-col gap-2 p-6", children: [_jsx("span", { className: "text-as-content-secondary text-sm font-medium", children: "Deposit address:" }), _jsxs("div", { className: "flex h-full cursor-pointer flex-col items-stretch justify-between gap-4", onClick: handleCopyAddress, children: [_jsx("div", { className: "text-as-primary break-all font-mono text-sm font-semibold leading-relaxed", children: order.globalAddress }), _jsx("div", { className: "place-self-end", children: _jsx(Copy, { className: "group-hover:text-as-brand text-as-tertiarry h-4 w-4 cursor-pointer transition-all duration-200" }) })] })] })] }), _jsx(OrderDetailsCollapsible, { order: order, dstToken: dstToken, tournament: tournament, nft: nft, recipientName: recipientName, formattedExpectedDstAmount: formattedExpectedDstAmount })] }), _jsx("div", { className: "flex flex-col gap-3", children: _jsx(ShinyButton, { accentColor: "hsl(var(--as-brand))", textColor: "text-white", className: "w-full py-3", onClick: handleCopyAddress, children: "Copy deposit address" }) })] }));
|
|
70
70
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { components } from "../../anyspend/types/api";
|
|
2
1
|
import { Account, Chain, PublicClient, Transport, WalletClient } from "viem";
|
|
3
2
|
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
3
|
+
import { components } from "../../anyspend/types/api";
|
|
4
4
|
export declare const EVM_MAINNET: Record<number, IEVMChain>;
|
|
5
5
|
export declare const EVM_TESTNET: Record<number, IEVMChain>;
|
|
6
6
|
export declare const SOLANA_MAINNET: ISolanaChain;
|
|
@@ -18,7 +18,7 @@ export declare function isMainnet(chainId: number): boolean;
|
|
|
18
18
|
export declare function isTestnet(chainId: number): boolean;
|
|
19
19
|
export declare function getDefaultToken(chainId: number): components["schemas"]["Token"];
|
|
20
20
|
export declare function getChainName(chainId: number): string;
|
|
21
|
-
export declare function getPaymentUrl(address: string, amount: bigint, currency: string
|
|
21
|
+
export declare function getPaymentUrl(address: string, amount: bigint, currency: string): string;
|
|
22
22
|
export declare function getExplorerTxUrl(chainId: number, txHash: string): string;
|
|
23
23
|
export declare function getExplorerAddressUrl(chainId: number, address: string): string;
|
|
24
24
|
export declare function getMulticall3Address(chainId: number): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "../../anyspend/constants/index.js";
|
|
2
1
|
import invariant from "invariant";
|
|
3
2
|
import { createPublicClient, createWalletClient, defineChain, http, parseEther, } from "viem";
|
|
4
3
|
import { arbitrum, avalanche, b3, b3Sepolia, base, baseSepolia, bsc, mainnet, optimism, polygon, sepolia, } from "viem/chains";
|
|
5
|
-
import {
|
|
4
|
+
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "../../anyspend/constants/index.js";
|
|
6
5
|
import { getAvaxToken, getBnbToken, getEthToken, getPolToken, getSolanaToken } from "./token.js";
|
|
6
|
+
import { ChainType } from "../types/chain.js";
|
|
7
7
|
function getCustomEvmChain(chain, rpcUrl) {
|
|
8
8
|
return defineChain({ ...chain, rpcUrls: { default: { http: [rpcUrl] } } });
|
|
9
9
|
}
|
|
@@ -237,46 +237,11 @@ export function getChainName(chainId) {
|
|
|
237
237
|
invariant(ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
|
|
238
238
|
return EVM_CHAINS[chainId] ? EVM_CHAINS[chainId].viem.name : "Solana";
|
|
239
239
|
}
|
|
240
|
-
export function getPaymentUrl(address, amount, currency
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const chain = ALL_CHAINS[chainId];
|
|
244
|
-
invariant(chain, `Chain ${chainId} is not supported`);
|
|
245
|
-
switch (chainType) {
|
|
246
|
-
case ChainType.EVM: {
|
|
247
|
-
// For EVM chains, follow EIP-681 format
|
|
248
|
-
// Format: ethereum:[address]@[chainId]?value=[amount]&symbol=[symbol]
|
|
249
|
-
const params = new URLSearchParams();
|
|
250
|
-
// Add value for native token transfers
|
|
251
|
-
if (currency === chain.nativeToken.symbol) {
|
|
252
|
-
params.append("value", amount.toString());
|
|
253
|
-
}
|
|
254
|
-
// Add chain ID for non-Ethereum chains
|
|
255
|
-
const chainParam = chainId !== mainnet.id ? `@${chainId}` : "";
|
|
256
|
-
// Add token info for non-native token transfers
|
|
257
|
-
if (currency !== chain.nativeToken.symbol) {
|
|
258
|
-
params.append("symbol", currency);
|
|
259
|
-
}
|
|
260
|
-
const queryString = params.toString();
|
|
261
|
-
return `ethereum:${address}${chainParam}${queryString ? `?${queryString}` : ""}`;
|
|
262
|
-
}
|
|
263
|
-
case ChainType.SOLANA: {
|
|
264
|
-
// Solana URL format: solana:${address}?amount=${amount}&spl-token=${tokenAddress}
|
|
265
|
-
const params = new URLSearchParams();
|
|
266
|
-
// Add amount for native SOL transfers
|
|
267
|
-
if (currency === "SOL") {
|
|
268
|
-
params.append("amount", amount.toString());
|
|
269
|
-
}
|
|
270
|
-
// Add SPL token info for token transfers
|
|
271
|
-
if (currency !== "SOL") {
|
|
272
|
-
params.append("spl-token", currency); // currency here should be token address
|
|
273
|
-
}
|
|
274
|
-
return `solana:${address}?${params.toString()}`;
|
|
275
|
-
}
|
|
276
|
-
default:
|
|
277
|
-
// Fallback to just the address if chain type is unknown
|
|
278
|
-
return address;
|
|
240
|
+
export function getPaymentUrl(address, amount, currency) {
|
|
241
|
+
if (currency === "ETH") {
|
|
242
|
+
return `ethereum:${address}?value=${amount.toString()}`;
|
|
279
243
|
}
|
|
244
|
+
return `ethereum:${address}`;
|
|
280
245
|
}
|
|
281
246
|
export function getExplorerTxUrl(chainId, txHash) {
|
|
282
247
|
if (chainId === b3.id) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
1
|
import { Account, Chain, PublicClient, Transport, WalletClient } from "viem";
|
|
3
2
|
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
3
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
4
4
|
export declare const EVM_MAINNET: Record<number, IEVMChain>;
|
|
5
5
|
export declare const EVM_TESTNET: Record<number, IEVMChain>;
|
|
6
6
|
export declare const SOLANA_MAINNET: ISolanaChain;
|
|
@@ -18,7 +18,7 @@ export declare function isMainnet(chainId: number): boolean;
|
|
|
18
18
|
export declare function isTestnet(chainId: number): boolean;
|
|
19
19
|
export declare function getDefaultToken(chainId: number): components["schemas"]["Token"];
|
|
20
20
|
export declare function getChainName(chainId: number): string;
|
|
21
|
-
export declare function getPaymentUrl(address: string, amount: bigint, currency: string
|
|
21
|
+
export declare function getPaymentUrl(address: string, amount: bigint, currency: string): string;
|
|
22
22
|
export declare function getExplorerTxUrl(chainId: number, txHash: string): string;
|
|
23
23
|
export declare function getExplorerAddressUrl(chainId: number, address: string): string;
|
|
24
24
|
export declare function getMulticall3Address(chainId: number): string;
|
package/package.json
CHANGED
|
@@ -1068,7 +1068,6 @@ export const OrderDetails = memo(function OrderDetails({
|
|
|
1068
1068
|
order.globalAddress,
|
|
1069
1069
|
BigInt(order.srcAmount),
|
|
1070
1070
|
order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress,
|
|
1071
|
-
order.srcChain,
|
|
1072
1071
|
)}
|
|
1073
1072
|
className="max-w-[200px]"
|
|
1074
1073
|
/>
|
|
@@ -194,7 +194,6 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
|
|
|
194
194
|
order.globalAddress,
|
|
195
195
|
BigInt(order.srcAmount),
|
|
196
196
|
order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress,
|
|
197
|
-
order.srcChain,
|
|
198
197
|
)}
|
|
199
198
|
className="bg-as-surface-secondary max-h-48 max-w-48"
|
|
200
199
|
/>
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend/constants";
|
|
2
|
-
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
1
|
import invariant from "invariant";
|
|
4
2
|
import {
|
|
5
3
|
Account,
|
|
@@ -26,8 +24,10 @@ import {
|
|
|
26
24
|
polygon,
|
|
27
25
|
sepolia,
|
|
28
26
|
} from "viem/chains";
|
|
29
|
-
import {
|
|
27
|
+
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend/constants";
|
|
30
28
|
import { getAvaxToken, getBnbToken, getEthToken, getPolToken, getSolanaToken } from "./token";
|
|
29
|
+
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
30
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
31
31
|
|
|
32
32
|
function getCustomEvmChain(chain: Chain, rpcUrl: string): Chain {
|
|
33
33
|
return defineChain({ ...chain, rpcUrls: { default: { http: [rpcUrl] } } });
|
|
@@ -304,56 +304,11 @@ export function getChainName(chainId: number): string {
|
|
|
304
304
|
return EVM_CHAINS[chainId] ? EVM_CHAINS[chainId].viem.name : "Solana";
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
export function getPaymentUrl(address: string, amount: bigint, currency: string
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const chain = ALL_CHAINS[chainId];
|
|
311
|
-
invariant(chain, `Chain ${chainId} is not supported`);
|
|
312
|
-
|
|
313
|
-
switch (chainType) {
|
|
314
|
-
case ChainType.EVM: {
|
|
315
|
-
// For EVM chains, follow EIP-681 format
|
|
316
|
-
// Format: ethereum:[address]@[chainId]?value=[amount]&symbol=[symbol]
|
|
317
|
-
const params = new URLSearchParams();
|
|
318
|
-
|
|
319
|
-
// Add value for native token transfers
|
|
320
|
-
if (currency === chain.nativeToken.symbol) {
|
|
321
|
-
params.append("value", amount.toString());
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
// Add chain ID for non-Ethereum chains
|
|
325
|
-
const chainParam = chainId !== mainnet.id ? `@${chainId}` : "";
|
|
326
|
-
|
|
327
|
-
// Add token info for non-native token transfers
|
|
328
|
-
if (currency !== chain.nativeToken.symbol) {
|
|
329
|
-
params.append("symbol", currency);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
const queryString = params.toString();
|
|
333
|
-
return `ethereum:${address}${chainParam}${queryString ? `?${queryString}` : ""}`;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
case ChainType.SOLANA: {
|
|
337
|
-
// Solana URL format: solana:${address}?amount=${amount}&spl-token=${tokenAddress}
|
|
338
|
-
const params = new URLSearchParams();
|
|
339
|
-
|
|
340
|
-
// Add amount for native SOL transfers
|
|
341
|
-
if (currency === "SOL") {
|
|
342
|
-
params.append("amount", amount.toString());
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Add SPL token info for token transfers
|
|
346
|
-
if (currency !== "SOL") {
|
|
347
|
-
params.append("spl-token", currency); // currency here should be token address
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
return `solana:${address}?${params.toString()}`;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
default:
|
|
354
|
-
// Fallback to just the address if chain type is unknown
|
|
355
|
-
return address;
|
|
307
|
+
export function getPaymentUrl(address: string, amount: bigint, currency: string) {
|
|
308
|
+
if (currency === "ETH") {
|
|
309
|
+
return `ethereum:${address}?value=${amount.toString()}`;
|
|
356
310
|
}
|
|
311
|
+
return `ethereum:${address}`;
|
|
357
312
|
}
|
|
358
313
|
|
|
359
314
|
export function getExplorerTxUrl(chainId: number, txHash: string) {
|