Skip to content

Commit

Permalink
website: use sepolia testnet for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek committed Dec 10, 2023
1 parent 201df5d commit d63f895
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 35 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pnpm add get-starknet-core starknet
2. Wrap your app with `StarknetConfig`

```typescript
import { goerli } from "@starknet-react/chains";
import { sepolia } from "@starknet-react/chains";
import {
StarknetConfig,
publicProvider,
Expand All @@ -45,31 +45,30 @@ import {
} from "@starknet-react/core";

function App() {
const chains = [goerli];
const chains = [sepolia];
const provider = publicProvider();
const connectors = [braavos(), argent()];

return (
<StarknetConfig chains={chains} provider={provider} connectors={connectors}>
<YourApp />
</StarknetConfig>
)
);
}
```

3. Access the hooks from your components.

```typescript
import { useAccount } from '@starknet-react/core'
import { useAccount } from "@starknet-react/core";

function YourComponent() {
const { address } = useAccount()
const { address } = useAccount();

return <div>gm {address}</div>
return <div>gm {address}</div>;
}
```

## License

This library is licensed under the MIT license.

16 changes: 15 additions & 1 deletion website/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SiteHeader } from "@/components/site-header";
import { cn } from "@/lib/utils";
import { monoFont, sansFont } from "@/lib/fonts";
import { JotaiProvider } from "@/components/jotai-provider";
import { Notice } from "@/components/notice";

export const metadata: Metadata = {
title: {
Expand All @@ -29,7 +30,7 @@ export default function RootLayout({
className={cn(
"min-h-screen bg-background font-sans antialiased",
sansFont.variable,
monoFont.variable,
monoFont.variable
)}
>
<ThemeProvider
Expand All @@ -40,6 +41,19 @@ export default function RootLayout({
>
<JotaiProvider>
<div className="relative flex min-h-screen flex-col">
<Notice>
<p>
Starknet testnet is migrating to Sepolia.{" "}
<a
href="https://medium.com/@Jonathanstarknet/next-version-of-starknet-v0-12-3-v0-13-0-and-migration-to-sepolia-testnet-88efd3a68d1c"
target="_blank"
className="underline"
>
Read more
</a>
.
</p>
</Notice>
<SiteHeader />
<div className="flex-1">{children}</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions website/components/notice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

export function Notice({ children }: { children: React.ReactNode }) {
return (
<div className="w-full bg-primary py-2 text-sm">
<div className="container">{children}</div>
</div>
);
}
4 changes: 2 additions & 2 deletions website/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ of recommended connectors with a dynamic list of injected connectors.
"use client";
import React from "react";

import { goerli, mainnet } from "@starknet-react/chains";
import { sepolia, mainnet } from "@starknet-react/chains";
import {
StarknetConfig,
publicProvider,
Expand All @@ -84,7 +84,7 @@ export function StarknetProvider({ children }: { children: React.ReactNode }) {

return (
<StarknetConfig
chains={[mainnet, goerli]}
chains={[mainnet, sepolia]}
provider={publicProvider()}
connectors={connectors}
explorer={voyager}
Expand Down
45 changes: 20 additions & 25 deletions website/content/hooks/useInjectedConnectors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
title: useInjectedConnectors
priority: 96
hookType: default

---

Hook for discovering injected connectors.

## Usage

```ts
import { sepolia, mainnet } from "@starknet-react/chains";
import {
StarknetConfig,
publicProvider,
Expand All @@ -19,26 +19,19 @@ import {
} from "@starknet-react/core";

export default function App({ children }) {
const chains = [goerli, mainnet];
const chains = [sepolia, mainnet];
const provider = publicProvider();
const { connectors } = useInjectedConnectors({
// Show these connectors if the user has no connector installed.
recommended: [
argent(),
braavos(),
],
recommended: [argent(), braavos()],
// Hide recommended connectors if the user has any connector installed.
includeRecommended: "onlyIfNoConnectors",
// Randomize the order of the connectors.
order: "random"
order: "random",
});

return (
<StarknetConfig
chains={chains}
provider={provider}
connectors={connectors}
>
<StarknetConfig chains={chains} provider={provider} connectors={connectors}>
{children}
</StarknetConfig>
);
Expand All @@ -47,21 +40,23 @@ export default function App({ children }) {

## Options

* __recommended?__`: Connector[]`
- List of recommended connectors.
- **recommended?**`: Connector[]`

- List of recommended connectors.

- **includeRecommended?**`: "always" | "onlyIfNoConnectors"`

* __includeRecommended?__`: "always" | "onlyIfNoConnectors"`
- If `"always"`, the hook always returns the recommended connectors.
- If `"onlyIfNoConnectors"`, the recommended connectors are included only if
no other connector is installed.
- If `"always"`, the hook always returns the recommended connectors.
- If `"onlyIfNoConnectors"`, the recommended connectors are included only if
no other connector is installed.

* __order?__`: "random" | "alphabetical"`
- Control the order in which connectors are returned.
- If `"random"`, connectors are shuffled.
- If `"alphabetical"`, connectors are alphabetically sorted by their id.
- **order?**`: "random" | "alphabetical"`
- Control the order in which connectors are returned.
- If `"random"`, connectors are shuffled.
- If `"alphabetical"`, connectors are alphabetically sorted by their id.

## Returns

* __connectors__`: Connector[]`
- Contains the list of injected connectors installed by the user.
- All connectors are unique and sorted.
- **connectors**`: Connector[]`
- Contains the list of injected connectors installed by the user.
- All connectors are unique and sorted.

0 comments on commit d63f895

Please sign in to comment.