Skip to content

Commit

Permalink
feat: prep for publish
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden committed Sep 25, 2024
1 parent 6bfa1b9 commit 7b99bdf
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 47 deletions.
28 changes: 13 additions & 15 deletions examples/react-vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,19 @@ export default function App() {
>
<Fragment>
<unified-wallet-modal
autoConnect={true}
disconnectOnAccountChange={false}
config={{
env: "mainnet-beta",
theme: "jupiter",
metadata: {
name: "UnifiedWallet69",
description: "UnifiedWallet69",
url: "https://jup.ag69",
iconUrls: ["https://jup.ag/favicon.ico/69"],
},
walletlistExplanation: {
href: "https://station.jup.ag/docs/additional-topics/wallet-list",
},
}}
// config={{
// env: "mainnet-beta",
// theme: "jupiter",
// metadata: {
// name: "UnifiedWallet69",
// description: "UnifiedWallet69",
// url: "https://jup.ag69",
// iconUrls: ["https://jup.ag/favicon.ico/69"],
// },
// walletlistExplanation: {
// href: "https://station.jup.ag/docs/additional-topics/wallet-list",
// },
// }}
/>
<Outlet />
<ScrollRestoration />
Expand Down
16 changes: 15 additions & 1 deletion examples/start-tailwind/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ export default function App() {
localStorageKey="unified:wallet-stoarge-key"
env={"devnet"}
>
<unified-wallet-modal />
<unified-wallet-modal
// config={{
// env: "mainnet-beta",
// theme: "jupiter",
// metadata: {
// name: "UnifiedWallet69",
// description: "UnifiedWallet69",
// url: "https://jup.ag69",
// iconUrls: ["https://jup.ag/favicon.ico/69"],
// },
// walletlistExplanation: {
// href: "https://station.jup.ag/docs/additional-topics/wallet-list",
// },
// }}
/>
<Nav />
<Suspense>{props.children}</Suspense>
</WalletProvider>
Expand Down
2 changes: 1 addition & 1 deletion examples/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@solana-wallets-solid/unified": "workspace:*"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-cloudflare": "^4.7.2",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"svelte": "^4.2.7",
Expand Down
12 changes: 8 additions & 4 deletions examples/sveltekit/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<script lang="ts">
import { initStore } from "@solana-wallets-solid/core"
import { initStore, type Cluster } from "@solana-wallets-solid/core"
import { onMount, setContext } from "svelte"
import "@solana-wallets-solid/unified/index.css"
export const env: Cluster | undefined = "mainnet-beta"
export const autoConnect: boolean = true
export const disconnectOnAccountChange: boolean = true
const {
$env: env,
$env: _env,
$wallet: wallet,
$wallets: wallets,
$connecting: connecting,
Expand All @@ -18,15 +22,15 @@
signTransactionV1,
signAllTransactionsV1,
getTransactionSendingSigner,
} = initStore({ autoConnect: true, disconnectOnAccountChange: true })
} = initStore({ env, autoConnect, disconnectOnAccountChange })
onMount(() => {
const cleanup = initOnMount()
return cleanup
})
setContext("unified", {
env,
env: _env,
wallet,
connectedAccount,
wallets,
Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export function initStore({ env, disconnectOnAccountChange }: StoreProps) {
onSet($connectedAccount, ({ newValue }) => {
dispatchWalletChanged(newValue)
})

const $isConnected = computed($connectedAccount, acc => !!acc)

const $wallet = computed([$connectedAccount, $walletsMap], (acc, walletsMap) => {
if (!acc) {
return
Expand All @@ -86,13 +86,16 @@ export function initStore({ env, disconnectOnAccountChange }: StoreProps) {
})

const $env = atom<Cluster>(env ?? "mainnet-beta")
onSet($env, ({ newValue }) => {
console.log("new env value: ", { newValue })
})

const $connecting = atom<boolean>(false)
onSet($connecting, ({ newValue }) => {
dispatchConnecting(newValue)
})

const $disconnecting = atom<boolean>(false)
// Selected wallet connection state
// export const $ready = atom<WalletReadyState>(WalletReadyState.Unsupported)

function onConnect(
event: StandardEventChangeProperties,
Expand Down Expand Up @@ -725,6 +728,8 @@ export function initStore({ env, disconnectOnAccountChange }: StoreProps) {
}

export type Store = ReturnType<typeof initStore>
// re-export types
export type { WalletName, WalletAdapterCompatibleStandardWallet }

// function getMobileWallet(wallets: WalletAdapterCompatibleStandardWallet[]) {
// /**
Expand Down
1 change: 0 additions & 1 deletion packages/solid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"devDependencies": {
"@nanostores/solid": "^0.4.2",
"@solana-mobile/wallet-adapter-mobile": "^2.1.3",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana-wallets-solid/core": "workspace:*",
"@solid-primitives/context": "^0.2.3",
"nanostores": "^0.11.3",
Expand Down
16 changes: 6 additions & 10 deletions packages/solid/src/useWallet.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useStore } from "@nanostores/solid"
import { createContextProvider } from "@solid-primitives/context"
import { onCleanup, onMount } from "solid-js"
import { createEffect, onCleanup, onMount } from "solid-js"
import { Cluster, initStore, dispatchConnect, dispatchDisconnect } from "@solana-wallets-solid/core"
import {} from "@solana/wallet-adapter-base"

export type WalletProviderProps = {
autoConnect: boolean
Expand Down Expand Up @@ -41,8 +40,6 @@ const [WalletProvider, _useWallet] = createContextProvider((props: WalletProvide
const connecting = useStore($connecting)
const disconnecting = useStore($disconnecting)

// Selected wallet connection state

onMount(() => {
const cleanup = initOnMount()
if (cleanup) {
Expand All @@ -52,6 +49,10 @@ const [WalletProvider, _useWallet] = createContextProvider((props: WalletProvide
}
})

createEffect(() => {
console.log("env value: ", { env: env() })
})

return {
env,
connected,
Expand All @@ -71,18 +72,13 @@ const [WalletProvider, _useWallet] = createContextProvider((props: WalletProvide
signAllTransactionsV1,
sendTransactionV1,
getTransactionSendingSigner,
// signTransaction,
// signMessage,
// signAllTransactions,
// sendTransaction,
//
}
})

const useWallet = () => {
const context = _useWallet()
if (!context) {
throw new Error("useWalelt must be used within a WalletProvider")
throw new Error("useWallet must be used within a WalletProvider")
}
return context
}
Expand Down
46 changes: 34 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7b99bdf

Please sign in to comment.