diff --git a/apps/playground/src/components/cardano/connect-browser-wallet.tsx b/apps/playground/src/components/cardano/connect-browser-wallet.tsx index 18822c153..b933b0f39 100644 --- a/apps/playground/src/components/cardano/connect-browser-wallet.tsx +++ b/apps/playground/src/components/cardano/connect-browser-wallet.tsx @@ -1,15 +1,42 @@ import { CardanoWallet, useWalletList } from "@meshsdk/react"; +import { getProvider } from "./mesh-wallet"; + export default function ConnectBrowserWallet() { const wallets = useWalletList(); const hasAvailableWallets = wallets.length > 0; return ( <> {hasAvailableWallets ? ( - + ) : ( <>No wallets installed )} ); } + +export function CommonCardanoWallet() { + const provider = getProvider(); + + return ( + + ); +} diff --git a/apps/playground/src/components/cardano/mesh-wallet.ts b/apps/playground/src/components/cardano/mesh-wallet.ts index 4667b0246..ad33bc58f 100644 --- a/apps/playground/src/components/cardano/mesh-wallet.ts +++ b/apps/playground/src/components/cardano/mesh-wallet.ts @@ -1,7 +1,11 @@ import { BlockfrostProvider, MeshWallet } from "@meshsdk/core"; export function getProvider(network = "preprod") { - return new BlockfrostProvider(`/api/blockfrost/${network}/`); + const blockchainProvider = new BlockfrostProvider( + `/api/blockfrost/${network}/`, + ); + blockchainProvider.setSubmitTxToBytes(false); + return blockchainProvider; } export function getMeshWallet() { diff --git a/apps/playground/src/components/sections/hero-two-sections.tsx b/apps/playground/src/components/sections/hero-two-sections.tsx index 33ec15fb1..d2be5df88 100644 --- a/apps/playground/src/components/sections/hero-two-sections.tsx +++ b/apps/playground/src/components/sections/hero-two-sections.tsx @@ -15,7 +15,7 @@ export default function HeroTwoSections({ children?: React.ReactNode; title: string; description: string; - image: string | React.ReactNode; + image?: string | React.ReactNode; link?: { label: string; href: string }; code?: string; }) { @@ -45,7 +45,7 @@ export default function HeroTwoSections({ {children &&
{children}
}
- {typeof image === "string" ? : image} + {image && typeof image === "string" ? : image}
diff --git a/apps/playground/src/pages/aiken/common.tsx b/apps/playground/src/pages/aiken/common.tsx index 0b719c62d..c8ab05d57 100644 --- a/apps/playground/src/pages/aiken/common.tsx +++ b/apps/playground/src/pages/aiken/common.tsx @@ -1,5 +1,5 @@ import { - BrowserWallet, + IWallet, PlutusScript, resolveDataHash, resolvePaymentKeyHash, @@ -20,7 +20,7 @@ export function getPageLinks() { export const compiledCode = `58f0010000323232323232323222232325333008323232533300b002100114a06644646600200200644a66602200229404c8c94ccc040cdc78010028a511330040040013014002375c60240026eb0c038c03cc03cc03cc03cc03cc03cc03cc03cc020c008c020014dd71801180400399b8f375c6002600e00a91010d48656c6c6f2c20576f726c6421002300d001149858c94ccc020cdc3a400000226464a66601a601e0042930b1bae300d00130060041630060033253330073370e900000089919299980618070010a4c2c6eb8c030004c01401058c01400c8c014dd5000918019baa0015734aae7555cf2ab9f5742ae89`; -export async function getWalletAddress(wallet: BrowserWallet) { +export async function getWalletAddress(wallet: IWallet) { const addresses = await wallet.getUsedAddresses(); const address = addresses[0]; diff --git a/apps/playground/src/pages/api/blockfrost/[...slug].ts b/apps/playground/src/pages/api/blockfrost/[...slug].ts index c99a43019..60b3d58be 100644 --- a/apps/playground/src/pages/api/blockfrost/[...slug].ts +++ b/apps/playground/src/pages/api/blockfrost/[...slug].ts @@ -1,6 +1,9 @@ import type { NextApiRequest, NextApiResponse } from "next"; import axios from "axios"; +import { bytesToHex, toBytes } from "@meshsdk/common"; +import { fromBytes } from "@meshsdk/core-csl"; + export default async function handler( _req: NextApiRequest, _res: NextApiResponse, @@ -43,18 +46,31 @@ export default async function handler( url += `${key}=${params[key]}&`; } } + // end get params if exists + if (url == "tx/submit") { + const body = _req.body; - /** - * call blockfrost api - */ - if (url == "tx/submit" || url == "utils/txs/evaluate") { + const headers = { "Content-Type": "application/cbor" }; + const { data, status } = await axiosInstance.post( + "tx/submit", + toBytes(body), + { + headers, + }, + ); + _res.status(status).json(data); + } else if (url == "utils/txs/evaluate") { const body = _req.body; const headers = { "Content-Type": "application/cbor" }; - const { data, status } = await axiosInstance.post(url, body, { - headers, - }); + const { status, data } = await axiosInstance.post( + "utils/txs/evaluate", + body, + { + headers, + }, + ); _res.status(status).json(data); } else { const { data, status } = await axiosInstance.get(`${url}`); diff --git a/apps/playground/src/pages/apis/txbuilder/basics/send-values.tsx b/apps/playground/src/pages/apis/txbuilder/basics/send-values.tsx index d5ede6e3c..c3927da4e 100644 --- a/apps/playground/src/pages/apis/txbuilder/basics/send-values.tsx +++ b/apps/playground/src/pages/apis/txbuilder/basics/send-values.tsx @@ -73,7 +73,7 @@ function Right() { const { wallet, connected } = useWallet(); const [address, setAddress] = useState(demoAddresses.testnet); - const [amount, setAmount] = useState("2000000"); + const [amount, setAmount] = useState("1000000"); async function runDemo() { const utxos = await wallet.getUtxos(); diff --git a/apps/playground/src/pages/apis/txbuilder/common.tsx b/apps/playground/src/pages/apis/txbuilder/common.tsx index b949cbf93..6bcbab011 100644 --- a/apps/playground/src/pages/apis/txbuilder/common.tsx +++ b/apps/playground/src/pages/apis/txbuilder/common.tsx @@ -6,6 +6,7 @@ export function getTxBuilder() { const blockchainProvider = getProvider(); const txBuilder = new MeshTxBuilder({ fetcher: blockchainProvider, + submitter: blockchainProvider, evaluator: blockchainProvider, verbose: true, }); diff --git a/apps/playground/src/pages/home/index.tsx b/apps/playground/src/pages/home/index.tsx index 5affc3777..b60398f23 100644 --- a/apps/playground/src/pages/home/index.tsx +++ b/apps/playground/src/pages/home/index.tsx @@ -14,7 +14,7 @@ export default function HomePage() { title="Web3 TypeScript SDK & off-chain Framework" description="Mesh is a TypeScript open-source library providing numerous tools to easily build powerful dApps on the Cardano blockchain." link={{ label: "Get started", href: "/getting-started" }} - image={