Skip to content

Commit

Permalink
Merge pull request #427 from MeshJS/feat-cip45
Browse files Browse the repository at this point in the history
Feat cip45
  • Loading branch information
jinglescode authored Dec 5, 2024
2 parents f578133 + 5a95998 commit 2c7fe86
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ export function CommonCardanoWallet() {
},
announce: [
"wss://dev.btt.cf-identity-wallet.metadata.dev.cf-deployments.org",
"wss://dev.tracker.cf-identity-wallet.metadata.dev.cf-deployments.org",
"wss://tracker.files.fm:7073/announce",
"wss://tracker.de-0.eternl.art",
],
}}
burnerWallet={{
Expand Down
16 changes: 11 additions & 5 deletions apps/playground/src/pages/react/ui-components/connect-wallet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { CardanoWallet } from "@meshsdk/react";

import { CommonCardanoWallet } from "~/components/cardano/connect-browser-wallet";
import Link from "~/components/link";
import LiveCodeDemo from "~/components/sections/live-code-demo";
Expand Down Expand Up @@ -121,10 +119,20 @@ function Left() {
<h3>CIP 95</h3>
<p>
You can also provide an <code>extensions</code> object to enable
specific CIPs. For example, to enable CIP95, you would pass:
specific CIPs. For example, to enable{" "}
<Link href="https://cips.cardano.org/cip/CIP-95">CIP-95</Link>, you
would pass:
</p>
<Codeblock data={codeCip95} />

<h3>Decentralized WebRTC dApp-Wallet Communication (CIP 45)</h3>
<p>
<Link href="https://cips.cardano.org/cip/CIP-45">CIP-45</Link> is a
communication method between dApps and wallets based on WebTorrent
trackers and WebRTC. Using WebTorrent trackers for the peer discovery to
remove the need of this central component.
</p>

<h3>Burner wallet</h3>
<p>
Burner wallets are wallets that are created on the fly on the user's
Expand All @@ -137,8 +145,6 @@ function Left() {
}

function Right() {
const isDark = useDarkmode((state) => state.isDark);

let example = ``;
example += `import { CardanoWallet } from '@meshsdk/react';\n`;
example += `\n`;
Expand Down
2 changes: 1 addition & 1 deletion packages/mesh-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/common",
"version": "1.7.27",
"version": "1.7.28",
"description": "Contains constants, types and interfaces used across the SDK and different serialization libraries",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-contract/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/contract",
"version": "1.7.27",
"version": "1.7.28",
"description": "List of open-source smart contracts, complete with documentation, live demos, and end-to-end source code. https://meshjs.dev/smart-contracts",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -34,9 +34,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.27",
"@meshsdk/core": "1.7.27",
"@meshsdk/core-csl": "1.7.27"
"@meshsdk/common": "1.7.28",
"@meshsdk/core": "1.7.28",
"@meshsdk/core-csl": "1.7.28"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions packages/mesh-core-csl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-csl",
"version": "1.7.27",
"version": "1.7.28",
"description": "Types and utilities functions between Mesh and cardano-serialization-lib",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
Expand Down Expand Up @@ -31,15 +31,15 @@
},
"devDependencies": {
"@meshsdk/configs": "*",
"@meshsdk/provider": "1.7.27",
"@meshsdk/provider": "1.7.28",
"@types/json-bigint": "^1.0.4",
"eslint": "^8.57.0",
"ts-jest": "^29.1.4",
"tsup": "^8.0.2",
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.27",
"@meshsdk/common": "1.7.28",
"@sidan-lab/sidan-csl-rs-browser": "0.9.8",
"@sidan-lab/sidan-csl-rs-nodejs": "0.9.8",
"@types/base32-encoding": "^1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-core-cst/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core-cst",
"version": "1.7.27",
"version": "1.7.28",
"description": "Types and utilities functions between Mesh and cardano-js-sdk",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -42,7 +42,7 @@
"@harmoniclabs/cbor": "1.3.0",
"@harmoniclabs/plutus-data": "1.2.4",
"@harmoniclabs/uplc": "1.2.4",
"@meshsdk/common": "1.7.27",
"@meshsdk/common": "1.7.28",
"@stricahq/bip32ed25519": "^1.1.0",
"@stricahq/cbors": "^1.0.3",
"pbkdf2": "^3.1.2"
Expand Down
16 changes: 8 additions & 8 deletions packages/mesh-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/core",
"version": "1.7.27",
"version": "1.7.28",
"description": "Mesh SDK Core - https://meshjs.dev/",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -33,13 +33,13 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.27",
"@meshsdk/core-csl": "1.7.27",
"@meshsdk/core-cst": "1.7.27",
"@meshsdk/provider": "1.7.27",
"@meshsdk/react": "1.7.27",
"@meshsdk/transaction": "1.7.27",
"@meshsdk/wallet": "1.7.27"
"@meshsdk/common": "1.7.28",
"@meshsdk/core-csl": "1.7.28",
"@meshsdk/core-cst": "1.7.28",
"@meshsdk/provider": "1.7.28",
"@meshsdk/react": "1.7.28",
"@meshsdk/transaction": "1.7.28",
"@meshsdk/wallet": "1.7.28"
},
"prettier": "@meshsdk/configs/prettier",
"publishConfig": {
Expand Down
6 changes: 3 additions & 3 deletions packages/mesh-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/provider",
"version": "1.7.27",
"version": "1.7.28",
"description": "Blockchain data providers - https://meshjs.dev/providers",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -34,8 +34,8 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.27",
"@meshsdk/core-cst": "1.7.27",
"@meshsdk/common": "1.7.28",
"@meshsdk/core-cst": "1.7.28",
"@utxorpc/sdk": "0.6.2",
"@utxorpc/spec": "0.10.1",
"axios": "^1.7.2"
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/react",
"version": "1.7.27",
"version": "1.7.28",
"description": "React component library - https://meshjs.dev/react",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -29,9 +29,9 @@
},
"dependencies": {
"@fabianbormann/cardano-peer-connect": "^1.2.18",
"@meshsdk/common": "1.7.27",
"@meshsdk/transaction": "1.7.27",
"@meshsdk/wallet": "1.7.27",
"@meshsdk/common": "1.7.28",
"@meshsdk/transaction": "1.7.28",
"@meshsdk/wallet": "1.7.28",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-icons": "^1.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function ConnectedButton() {

return (
<DropdownMenu>
<DropdownMenuTrigger>
<DropdownMenuTrigger asChild>
<Button variant="outline" className="mesh-text-white">
{address.slice(0, 6)}...{address.slice(-6)}
</Button>
Expand Down
5 changes: 4 additions & 1 deletion packages/mesh-react/src/cardano-wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export const CardanoWallet = ({
/>
)}
{screen == "p2p" && (
<ScreenP2P cardanoPeerConnect={cardanoPeerConnect} />
<ScreenP2P
cardanoPeerConnect={cardanoPeerConnect}
setOpen={setOpen}
/>
)}
{screen == "burner" && burnerWallet && (
<ScreenBurner
Expand Down
20 changes: 12 additions & 8 deletions packages/mesh-react/src/cardano-wallet/screen-p2p.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { useEffect, useRef, useState } from "react";

import { Button } from "../common/button";
import { DAppPeerConnect, IWalletInfo } from "../common/cardano-peer-connect";
import { useWallet } from "../hooks";

export default function ScreenP2P({
cardanoPeerConnect,
setOpen,
}: {
cardanoPeerConnect?: {
dAppInfo: {
Expand All @@ -13,11 +15,13 @@ export default function ScreenP2P({
};
announce: string[];
};
setOpen: Function;
}) {
const dAppConnect = useRef<DAppPeerConnect | null>(null);
const qrCodeField = useRef<HTMLDivElement | null>(null);
const [address, setAddress] = useState("");
const [copied, setCopied] = useState(false);
const { connect } = useWallet();

useEffect(() => {
if (cardanoPeerConnect) {
Expand All @@ -28,23 +32,25 @@ export default function ScreenP2P({
url: cardanoPeerConnect.dAppInfo.url,
},
announce: cardanoPeerConnect.announce,
onApiInject: (name: string, address: string) => {
console.log("onApiInject", name, address);
onApiInject: async (name: string, address: string) => {
console.log(5, "onApiInject", name, address);
await connect(name);
setOpen(false);
},
onApiEject: (name: string, address: string) => {
console.log("onApiEject", name, address);
console.log(5, "onApiEject", name, address);
},
onConnect: (address: string, walletInfo?: IWalletInfo) => {
console.log("Connected to wallet", address, walletInfo);
console.log(5, "Connected to wallet", address, walletInfo);
},
onDisconnect: () => {
console.log("Disconnected from wallet");
console.log(5, "Disconnected from wallet");
},
verifyConnection: (
walletInfo: IWalletInfo,
callback: (granted: boolean, autoconnect: boolean) => void,
) => {
console.log("verifyConnection", walletInfo);
console.log(5, "verifyConnection", walletInfo);
callback(true, true);
},
useWalletDiscovery: true,
Expand All @@ -53,8 +59,6 @@ export default function ScreenP2P({
if (dAppConnect.current) {
const address = dAppConnect.current.getAddress();
setAddress(address);
console.log("address", address);

if (qrCodeField.current !== null) {
dAppConnect.current.generateQRCode(qrCodeField.current);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mesh-svelte/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/svelte",
"version": "1.7.27",
"version": "1.7.28",
"description": "Svelte component library - https://meshjs.dev/svelte",
"type": "module",
"exports": {
Expand All @@ -26,7 +26,7 @@
"dev": "vite dev"
},
"dependencies": {
"@meshsdk/core": "1.7.27"
"@meshsdk/core": "1.7.28"
},
"devDependencies": {
"@meshsdk/configs": "*",
Expand Down
8 changes: 4 additions & 4 deletions packages/mesh-transaction/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/transaction",
"version": "1.7.27",
"version": "1.7.28",
"description": "Transactions - https://meshjs.dev/apis/transaction",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,9 +35,9 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.27",
"@meshsdk/core-csl": "1.7.27",
"@meshsdk/core-cst": "1.7.27",
"@meshsdk/common": "1.7.28",
"@meshsdk/core-csl": "1.7.28",
"@meshsdk/core-cst": "1.7.28",
"json-bigint": "^1.0.0"
},
"prettier": "@meshsdk/configs/prettier",
Expand Down
10 changes: 5 additions & 5 deletions packages/mesh-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@meshsdk/wallet",
"version": "1.7.27",
"version": "1.7.28",
"description": "Wallets - https://meshjs.dev/apis/wallets",
"main": "./dist/index.cjs",
"browser": "./dist/index.js",
Expand Down Expand Up @@ -35,10 +35,10 @@
"typescript": "^5.3.3"
},
"dependencies": {
"@meshsdk/common": "1.7.27",
"@meshsdk/core-csl": "1.7.27",
"@meshsdk/core-cst": "1.7.27",
"@meshsdk/transaction": "1.7.27",
"@meshsdk/common": "1.7.28",
"@meshsdk/core-csl": "1.7.28",
"@meshsdk/core-cst": "1.7.28",
"@meshsdk/transaction": "1.7.28",
"@nufi/dapp-client-cardano": "0.3.5",
"@nufi/dapp-client-core": "0.3.5"
},
Expand Down
2 changes: 1 addition & 1 deletion scripts/mesh-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.",
"homepage": "https://meshjs.dev",
"author": "MeshJS",
"version": "1.7.27",
"version": "1.7.28",
"license": "Apache-2.0",
"type": "module",
"main": "./dist/index.cjs",
Expand Down
3 changes: 2 additions & 1 deletion scripts/mesh-cli/src/actions/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ export const create = async (name, options) => {
const template =
options.template ??
(await askUser('What template do you want to use?', [
{ title: "Aiken", value: "mesh-aiken" },
{ title: "NextJS", value: "mesh-nextjs" },
{ title: "Svelte", value: "mesh-svelte" },
{ title: "Aiken", value: "mesh-aiken" },
]));

console.log('\n');
Expand Down
3 changes: 2 additions & 1 deletion scripts/mesh-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
InvalidArgumentError,
} from "commander";
import { create } from "./actions";
import { logError, logSuccess } from "./utils";
import { logError, logSuccess, logInfo } from "./utils";

const main = async () => {
console.clear();
Expand Down Expand Up @@ -72,6 +72,7 @@ const main = async () => {
main()
.then(() => {
logSuccess("✨✨ Welcome to Web 3.0! ✨✨");
logInfo('Run "cd <project-name>" and "npm run dev" to start your dApp.');
process.exit(0);
})
.catch((error) => {
Expand Down

0 comments on commit 2c7fe86

Please sign in to comment.