Skip to content
Open
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
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@creit.tech/stellar-wallets-kit": "^0.0.0-beta.0",
"@stellar/stellar-sdk": "^13.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"sorokit-core": "^0.1.0"
},
"peerDependencies": {
"tailwindcss": "^3.0.0"
Expand Down
57 changes: 6 additions & 51 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,8 @@
import { useState } from 'react'
import { ClientAdapter } from './lib/adapter'
import './App.css'
import { useSorokit } from "@/context/useSorokit";
import { ConnectScreen } from "@/screens/ConnectScreen";
import { Dashboard } from "@/screens/Dashboard";

interface AppProps {
adapter: ClientAdapter
export default function App() {
const { isConnected } = useSorokit();
return isConnected ? <Dashboard /> : <ConnectScreen />;
}

function App({ adapter }: AppProps) {
const [address, setAddress] = useState<string | null>(null)
const [error, setError] = useState<string | null>(null)
const [loading, setLoading] = useState(false)

const handleConnect = async () => {
setLoading(true)
setError(null)

const result = await adapter.connect()

if (result.status === 'error') {
setError(result.error)
} else {
setAddress(result.data)
}

setLoading(false)
}

return (
<div className="App">
<h1>Sorokit UI</h1>

{error && (
<div className="error-banner">
{error}
</div>
)}

{address ? (
<div className="connected">
<p>Connected: {address.substring(0, 8)}...</p>
<button onClick={() => adapter.disconnect()}>Disconnect</button>
</div>
) : (
<button onClick={handleConnect} disabled={loading}>
{loading ? 'Connecting...' : 'Connect Wallet'}
</button>
)}
</div>
)
}

export default App
Loading