Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add packages #34

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions src/commands/playground.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from "commander";
import path from "path";
import { createServer } from 'vite';
import { createServer } from "vite";

export const playgroundCommand = new Command()
.name("playground")
Expand All @@ -16,15 +16,16 @@ export const playgroundCommand = new Command()
server: {
port: port
},
configFile: path.resolve(dir, 'vite.config.ts'),
configFile: path.resolve(dir, "vite.config.ts"),

});

await server.listen();

server.printUrls();

// Handle process termination
process.on('SIGINT', async () => {
process.on("SIGINT", async () => {
await server.close();
process.exit();
});
Expand Down
Binary file modified src/playground/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion src/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
Expand Down
3 changes: 3 additions & 0 deletions src/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"preview": "vite preview"
},
"dependencies": {
"@bitte-ai/chat": "0.1.0-animation-color-5f2c527",
"@mintbase-js/react": "latest",
"@near-wallet-selector/modal-ui": "^8.9.15",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
Expand Down
Binary file added src/playground/public/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion src/playground/public/vite.svg

This file was deleted.

42 changes: 0 additions & 42 deletions src/playground/src/App.css

This file was deleted.

78 changes: 49 additions & 29 deletions src/playground/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
"use client";

function App() {
const [count, setCount] = useState(0)
import { BitteAiChat } from "@bitte-ai/chat";
import "@bitte-ai/chat/style.css";
import { useBitteWallet, Wallet } from "@mintbase-js/react";
import { useEffect, useState } from "react";
import "./shims";
import "@bitte-ai/chat/style.css";
import { Header } from "./Header";

const bitteAgent = {
id: "bitte-assistant",
name: "Bitte Assistant",
description:
"Bitte assistant for interacting with NFTs and Fungible Tokens (FTs) on NEAR Protocol. Users can query, mint, transfer NFTs, transfer FTs, create drops, and swap tokens.",
verified: true,
image: "/bitte.svg",
};


const Main: React.FC = () => {
const { selector } = useBitteWallet();
const [wallet, setWallet] = useState<Wallet>();

useEffect(() => {
const fetchWallet = async () => {
const walletInstance = await selector.wallet();
setWallet(walletInstance);
};
if (selector) fetchWallet();
}, [selector]);

return (
<>
<main>
<Header />
<div>
<a href="https://vite.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
<BitteAiChat
options={{ agentImage: bitteAgent.image, agentName: bitteAgent.name }}
agentid={bitteAgent.id}
wallet={{ near: { wallet } }}
apiUrl="/api/chat"
colors={{
generalBackground: "#18181A",
messageBackground: "#0A0A0A",
textColor: "#FAFAFA",
buttonColor: "#000000",
borderColor: "#334155",
}}
/>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
}
</main>
);
};

export default App
export default Main;
5 changes: 5 additions & 0 deletions src/playground/src/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { NearWalletConnector } from "./WalletConnector";

export const Header = () => {
return <header><NearWalletConnector /></header>;
};
34 changes: 34 additions & 0 deletions src/playground/src/WalletConnector.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useBitteWallet } from "@mintbase-js/react";

export const NearWalletConnector = () => {
const { isConnected, selector, connect, activeAccountId } = useBitteWallet();

const handleSignout = async () => {
const wallet = await selector.wallet();
return wallet.signOut();
};

const handleSignIn = async () => {
return connect();
};

if (!isConnected) {
return (
<button className="connect-button" onClick={handleSignIn}>
Connect Wallet
</button>
);
}

return (
<div>
<p>You are connected as {activeAccountId}</p>
<div className="container">
<button className="disconnect-button" onClick={handleSignout}>
{" "}
Disconnect{" "}
</button>
</div>
</div>
);
};
98 changes: 45 additions & 53 deletions src/playground/src/index.css
Original file line number Diff line number Diff line change
@@ -1,68 +1,60 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
@tailwind base;
@tailwind components;
@tailwind utilities;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
main > div {
width: 700px;
margin: 0 auto;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
body {
background-color: #242424;
}

body {
margin: 0;
header {
width: 100%;
text-align: center;
margin: 20px 0;
height: 100px;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
justify-content: center;
align-items: center;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
p,
.bitte-text-gray-40 {
color: rgba(255, 255, 255, 0.87);
}

.connect-button {
background-color: white;
color: black;
border-radius: 0.375rem; /* Equivalent to Tailwind's rounded */
padding: 0.75rem; /* Equivalent to Tailwind's p-3 */
transition: background-color 0.2s;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
.connect-button:hover {
background-color: #e1e1e1;
}
button:hover {
border-color: #646cff;

/* Styles for the disconnect button */
.disconnect-button {
background-color: white;
color: black;
border-radius: 0.375rem;
padding: 0.75rem;
transition: background-color 0.2s;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;

.disconnect-button:hover {
background-color: #e1e1e1;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
/* Styles for the container div */
.container {
display: flex;
justify-content: center;
align-items: center;
margin-top: 1rem; /* Equivalent to Tailwind's mt-4 */
}
24 changes: 17 additions & 7 deletions src/playground/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.tsx'
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App.tsx";
import { BitteWalletContextProvider } from "@mintbase-js/react";
import "@near-wallet-selector/modal-ui/styles.css";

createRoot(document.getElementById('root')!).render(
const BitteWalletSetup = {
network: "mainnet",
callbackUrl: typeof window !== "undefined" ? window.location.origin : "",
contractAddress: "",
};

createRoot(document.getElementById("root")!).render(
<StrictMode>
<App />
<BitteWalletContextProvider {...BitteWalletSetup} onlyBitteWallet={true}>
<App />
</BitteWalletContextProvider>
</StrictMode>,
)
);
5 changes: 5 additions & 0 deletions src/playground/src/shims.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Buffer } from "buffer";
Object.assign(self, {
global: self,
Buffer,
});
7 changes: 5 additions & 2 deletions src/playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})
define: {
global: "globalThis",
'process.env': {}
},
})