Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jinglescode committed Aug 31, 2024
1 parent 0596db2 commit 9d2c932
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/playground/src/components/layouts/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Sidebar({
{sidebarItems.map((item, i) => {
return (
<li key={i}>
{item.to.startsWith("/") ? (
{item.to.startsWith("/") || item.to.startsWith("http") ? (
<Link href={item.to}>{item.label}</Link>
) : (
<LinkWithinPage key={i} item={item} />
Expand Down
6 changes: 6 additions & 0 deletions apps/playground/src/data/links-yaci.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { MenuItem } from "~/types/menu-item";

export const metaYaciHosted = {
title: "Hosted Yaci Devnet",
desc: "Connect to the hosted Yaci Devnet",
link: "https://cloud.meshjs.dev/yaci",
};
export const metaYaciGettingStarted = {
title: "Getting Started",
desc: "Set up Yaci Dev Kit and start the devnet",
Expand All @@ -17,6 +22,7 @@ export const metaYaciProvider = {
};
export const linksYaci: MenuItem[] = [
metaYaciGettingStarted,
metaYaciHosted,
metaYaciTransactions,
metaYaciProvider,
];
Expand Down
2 changes: 1 addition & 1 deletion apps/playground/src/hooks/useProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useProviders = create<State>(
set({ maestroKey: { network, apiKey } }),
koiosKey: undefined,
setKoiosKey: (network, apiKey) => set({ koiosKey: { network, apiKey } }),
yaciUrl: "http://localhost:8080/api/v1/",
yaciUrl: "https://yaci-node.meshjs.dev/api/v1/",
setYaciUrl: (url) => set({ yaciUrl: url }),
ogmiosUrl: "",
setOgmiosUrl: (url) => set({ ogmiosUrl: url }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ function Left() {
to sign arbitrary data, to verify the data was signed by the owner of
the private key.
</p>
<p>
<code>signData</code> takes two arguments, the first one is the payload
to sign and the second one is the address (optional).
</p>
<p>Example of a response from the endpoint:</p>
<Codeblock data={example} />
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ Lastly, we will return the **nonce** for the user to sign using their private ke

## Client: Verify ownership by signing the nonce

We are ready to use the private key associated with the wallet to sign the nonce with **await wallet.signData(userAddress, nonce)**, which enables the dApp to request the user to sign a payload according to [CIP-8](https://cips.cardano.org/cips/cip8/).
We are ready to use the private key associated with the wallet to sign the nonce with **await wallet.signData(nonce, userAddress)**, which enables the dApp to request the user to sign a payload according to [CIP-8](https://cips.cardano.org/cips/cip8/).

We request the user's authorization and show them the message that is to be signed: **Sign to login in to Mesh: nonce**. Once accepted, the signature will be generated and the dApp will process the signature to authenticate the user.

```
async function frontendSignMessage(nonce) {
try {
const userAddress = (await wallet.getRewardAddresses())[0];
const signature = await wallet.signData(userAddress, nonce);
const signature = await wallet.signData(nonce, userAddress);
// do: send request with 'signature' and 'userAddress' to the backend
} catch (error) {
Expand Down Expand Up @@ -175,7 +175,7 @@ export default function Page() {
async function frontendSignMessage(nonce) {
try {
const userAddress = (await wallet.getRewardAddresses())[0];
const signature = await wallet.signData(userAddress, nonce);
const signature = await wallet.signData(nonce, userAddress);
await backendVerifySignature(userAddress, signature);
} catch (error) {
setState(0);
Expand Down
46 changes: 46 additions & 0 deletions apps/playground/src/pages/yaci/getting-started/hosted.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Link from "~/components/link";
import TwoColumnsScroll from "~/components/sections/two-columns-scroll";
import Codeblock from "~/components/text/codeblock";

export default function YaciHosted() {
return (
<TwoColumnsScroll
sidebarTo="hosted"
title="Mesh Hosted Yaci Devnet"
leftSection={Left()}
/>
);
}

function Left() {
let code = "";
code += `import { YaciProvider } from "@meshsdk/core";\n`;
code += `\n`;
code += `const blockchainProvider = new YaciProvider();\n`;
code += `const params = await blockchainProvider.fetchProtocolParameters();\n`;
code += `console.log(params);\n`;

return (
<>
<h3>Connect right away with Yaci Provider</h3>
<p>
Mesh has a hosted Yaci Devnet that you can connect to right away. You
can use the following URL to connect to the hosted Yaci Devnet:
</p>
<Codeblock data={`https://yaci-node.meshjs.dev/api/v1/`} />
<h3>Import Yaci Provider</h3>
<p>
Import <code>YaciProvider</code> and start using it to interact with the
Yaci Devnet.
</p>
<Codeblock data={code} />
<p>
<Link href="/yaci/transactions/provider">
Learn more about Yaci Provider
</Link>{" "}
and learn more about{" "}
<Link href="https://cloud.meshjs.dev/yaci">hosted Yaci Devnet</Link>
</p>
</>
);
}
2 changes: 2 additions & 0 deletions apps/playground/src/pages/yaci/getting-started/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Metatags from "~/components/site/metatags";
import { metaYaciGettingStarted } from "~/data/links-yaci";
import { getPageLinks } from "../common";
import YaciCommands from "./commands";
import YaciHosted from "./hosted";
import YaciSetup from "./setup";
import YaciStart from "./start";

Expand All @@ -24,6 +25,7 @@ const ReactPage: NextPage = () => {
<></>
</TitleIconDescriptionBody>

<YaciHosted />
<YaciSetup />
<YaciStart />
<YaciCommands />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Left() {
function Right() {
const [userInput, setUserInput] = useState<string>(yaci.address);
const [userInput2, setUserInput2] = useState<string>(
"http://localhost:8080/api/v1/",
"https://yaci-node.meshjs.dev/api/v1/",
);

async function runDemo() {
Expand Down
4 changes: 2 additions & 2 deletions apps/playground/src/pages/yaci/transactions/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Left() {
/>
<p>
By default, the <code>YaciProvider</code> will use the default URL,{" "}
<code>http://localhost:8080/api/v1/</code>. If you want to use a custom
<code>https://yaci-node.meshjs.dev/api/v1/</code>. If you want to use a custom
URL, you can pass it as a parameter.
</p>
<p>
Expand All @@ -54,7 +54,7 @@ function Right() {
demoAddresses.testnetPayment,
);
const [userInput2, setUserInput2] = useState<string>(
"http://localhost:8080/api/v1/",
"https://yaci-node.meshjs.dev/api/v1/",
);

async function runDemo() {
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-provider/src/yaci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class YaciProvider
* Set the URL of the instance.
* @param baseUrl The base URL of the instance.
*/
constructor(baseUrl = "http://localhost:8080/api/v1/") {
constructor(baseUrl = "https://yaci-node.meshjs.dev/api/v1/") {
this._axiosInstance = axios.create({
baseURL: baseUrl,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-provider/test/yaci/evaluator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { YaciProvider } from "@meshsdk/provider";

const provider = new YaciProvider("http://localhost:8080/api/v1/");
const provider = new YaciProvider("https://yaci-node.meshjs.dev/api/v1/");

const successTx =
"84a60081825820ab11b83c9d46edf3e4f0124eccaec9c3469c4aa8bba47885991ea33f76f92d32000182825839005867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f9d4dcd7e454d2434164f4efb8edeb358d86a1dad9ec6224cfcbce3e6821a00111958a1581c9026ea35a0b0ca28e304ef94cc5a31c9e850db14a32dc3c69969fe83a14001825839005867c3b8e27840f556ac268b781578b14c5661fc63ee720dbeab663f9d4dcd7e454d2434164f4efb8edeb358d86a1dad9ec6224cfcbce3e61a3b89b0a8020009a1581c9026ea35a0b0ca28e304ef94cc5a31c9e850db14a32dc3c69969fe83a140010b5820df2de8c102f948422412af199867e5d472b9ff700473b2841e63209041b0e7df0d81825820ab11b83c9d46edf3e4f0124eccaec9c3469c4aa8bba47885991ea33f76f92d3200a20681590288590285010000332323232323232323232223232322533300832323232533300c3007300e3754002264a66601a6010601e6ea802454ccc034c020c03cdd519198008009bac30143011375400844a666026002298103d87a80001323253330113375e01e601260286ea80084cdd2a40006602c00497ae01330040040013017002301500114a229404c8cc004004c8cc004004c8cc004004dd5980b180b980b980b980b98099baa00622533301500114bd6f7b630099191919299980a99b9148900002153330153371e9101000021003100513301a337606ea4008dd3000998030030019bab3017003375c602a0046032004602e00244a666028002297ae0132333222323300100100322533301a00110031323301c374e660386ea4018cc070c064004cc070c0680052f5c066006006603c00460380026eb8c04c004dd5980a00099801801980c001180b0009129998098008a5113253330103253330113371e6eb8c0240040144cdc41bad301730183018001480005289bac301600213300300300114a0602c0026eb8c048c03cdd50008a50301130120023010001300c37540044601e0022930a99804a491856616c696461746f722072657475726e65642066616c7365001365632533300730020011533300b300a37540062930a998040030b0a99980399b874800800454ccc02cc028dd50018a4c2a6601000c2c2a6601000c2c60106ea8008dc3a4000a66666601800220022a6600a0062c2a6600a0062c2a6600a0062c2a6600a0062c92011672656465656d65723a204d696e74506f6c6172697479005734ae7155ceaab9e5573eae815d0aba257489812bd8799fd8799f5820ab11b83c9d46edf3e4f0124eccaec9c3469c4aa8bba47885991ea33f76f92d32ff00ff00010581840100d87980821a006acfc01ab2d05e00f5f6";
Expand Down

0 comments on commit 9d2c932

Please sign in to comment.