Skip to content

Commit

Permalink
Merge pull request #69 from okto-hq/zaje-patch
Browse files Browse the repository at this point in the history
Update supported chains, SDK section structure
  • Loading branch information
oviawork authored Feb 20, 2025
2 parents a788e84 + bca03a9 commit 7a776f3
Show file tree
Hide file tree
Showing 120 changed files with 4,697 additions and 1,243 deletions.
27 changes: 15 additions & 12 deletions app/components/mdx/QuickStartBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { SiTypescript } from "react-icons/si";
import Link from "next/link";

export default function QuickStartBanner() {
const baseButtonStyles = "relative group no-underline p-3 rounded-md border-2 border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800 shadow-md transition-all";
const baseIconStyles = "transition-transform transition-colors duration-200 ease-in-out group-hover:scale-110";

return (
<div className="flex flex-col lg:flex-row items-center justify-between px-6 py-4 mb-8 bg-gradient-to-r from-zinc-50 to-zinc-100 dark:from-zinc-900 dark:to-zinc-800 rounded-lg border-2 border-zinc-200 dark:border-zinc-700 hover:border-zinc-300 dark:hover:border-zinc-600 transition-all shadow-sm">
<div className="flex-1 pr-4 mb-6 lg:mb-0">
Expand All @@ -16,51 +19,51 @@ export default function QuickStartBanner() {
</div>
<div className="flex gap-6 items-center flex-wrap justify-center">
<Link
href="/docs/quickstart/new-okto-react-setup"
className="relative group no-underline p-3 rounded-md border-2 border-zinc-200 dark:border-zinc-700 hover:border-zinc-300 dark:hover:border-zinc-600 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-all"
href="/docs/react-sdk/quickstart/new-okto-react-setup"
className={baseButtonStyles}
>
<FaReact
size={36}
className="text-zinc-600 dark:text-zinc-400 transition-transform transition-colors duration-200 ease-in-out group-hover:scale-110 group-hover:text-[#61dafb]"
className={`${baseIconStyles} text-[#61dafb] opacity-80 group-hover:opacity-100`}
/>
<span className="absolute left-1/2 transform -translate-x-1/2 top-full mt-2 w-max px-2 py-1 text-xs text-white bg-zinc-900 dark:bg-zinc-200 dark:text-black rounded-md opacity-0 group-hover:opacity-100 transition-opacity">
React Quickstart
</span>
</Link>

<Link
href="/docs/quickstart/new-okto-nextjs-setup"
className="relative group no-underline p-3 rounded-md border-2 border-zinc-200 dark:border-zinc-700 hover:border-zinc-300 dark:hover:border-zinc-600 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-all"
href="/docs/nextjs-sdk/quickstart/new-okto-nextjs-setup"
className={baseButtonStyles}
>
<TbBrandNextjs
size={36}
className="text-zinc-600 dark:text-zinc-400 transition-transform transition-colors duration-200 ease-in-out group-hover:scale-110 group-hover:text-black dark:group-hover:text-white"
className={`${baseIconStyles} text-black dark:text-white opacity-80 group-hover:opacity-100`}
/>
<span className="absolute left-1/2 transform -translate-x-1/2 top-full mt-2 w-max px-2 py-1 text-xs text-white bg-zinc-900 dark:bg-zinc-200 dark:text-black rounded-md opacity-0 group-hover:opacity-100 transition-opacity">
Next.js Quickstart
</span>
</Link>

<Link
href="/docs/quickstart/new-okto-react-native-setup"
className="relative group no-underline p-3 rounded-md border-2 border-zinc-200 dark:border-zinc-700 hover:border-zinc-300 dark:hover:border-zinc-600 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-all"
href="/docs/react-native-sdk/quickstart/new-okto-react-native-setup"
className={baseButtonStyles}
>
<TbBrandReactNative
size={36}
className="text-zinc-600 dark:text-zinc-400 transition-transform transition-colors duration-200 ease-in-out group-hover:scale-110 group-hover:text-purple-500"
className={`${baseIconStyles} text-purple-500 opacity-80 group-hover:opacity-100`}
/>
<span className="absolute left-1/2 transform -translate-x-1/2 top-full mt-2 w-max px-2 py-1 text-xs text-white bg-zinc-900 dark:bg-zinc-200 dark:text-black rounded-md opacity-0 group-hover:opacity-100 transition-opacity">
React Native Quickstart
</span>
</Link>

<Link
href="/docs/quickstart/new-okto-typescript-setup"
className="relative group no-underline p-3 rounded-md border-2 border-zinc-200 dark:border-zinc-700 hover:border-zinc-300 dark:hover:border-zinc-600 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-all"
href="/docs/typescript-sdk/quickstart/new-okto-typescript-setup"
className={baseButtonStyles}
>
<SiTypescript
size={36}
className="text-zinc-600 dark:text-zinc-400 transition-transform transition-colors duration-200 ease-in-out group-hover:scale-110 group-hover:text-[#3178c6]"
className={`${baseIconStyles} text-[#3178c6] opacity-80 group-hover:opacity-100`}
/>
<span className="absolute left-1/2 transform -translate-x-1/2 top-full mt-2 w-max px-2 py-1 text-xs text-white bg-zinc-900 dark:bg-zinc-200 dark:text-black rounded-md opacity-0 group-hover:opacity-100 transition-opacity">
TypeScript Quickstart
Expand Down
4 changes: 2 additions & 2 deletions content/docs/flutter-sdk/technical-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ const order = {
| `amount` | Transfer amount | number \| bigint |
| `recipient` | Recipient's address | Address |
| `token` | Token address (empty for native) | Address \| '' |
| `chain` | Chain identifier | string |
| `caip2Id` | Chain identifier | string |

```typescript
const tokenTransferParams = {
amount: 1000000000n,
recipient: "0x123...",
token: "", // Native token
chain: "eip155:1"
caip2Id: "eip155:1"
};
```
</Accordion>
Expand Down
1 change: 1 addition & 0 deletions content/docs/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"---SDK---",
"okto-sdk",
"react-sdk",
"nextjs-sdk",
"react-native-sdk",
"!flutter-sdk",
"!unity-sdk",
Expand Down
5 changes: 5 additions & 0 deletions content/docs/nextjs-sdk/(Account)/estimate.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Estimate (Coming Soon)
description: A complete guide to integrating Okto into your React applications.
full: false
---
79 changes: 79 additions & 0 deletions content/docs/nextjs-sdk/(Account)/executeUserOp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: Execute UserOp
description: Learn how to execute user operations using the Okto SDK.
full: false
---

import { TypeTable } from 'fumadocs-ui/components/type-table';
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
import { Callout } from 'fumadocs-ui/components/callout';
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
import { Icon as IIcon } from '@iconify/react';

The `executeUserOp()` method is available on the OktoClient instance and is used to submit signed user operations to the blockchain. This method is used to execute transactions after they have been signed.

### Method Overview

| Methods | Description |
|---------|-------------|
| <sub><i>async</i></sub> [`oktoClient.executeUserOp`](#execute-userop) | Execute a signed user operation |

<div className="method-box">

## Execute UserOp

<sub><i>async</i></sub> `oktoClient.executeUserOp(userop: UserOp)` executes a signed user operation on the blockchain.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `userop` | [`UserOp`](/docs/react-sdk/technical-reference#models) | The signed user operation to be executed |

### Response

<Callout title="Success Response">

| Field Name | Type | Description |
|------------|------|-------------|
| `result` | `Promise<string>` | Returns the transaction hash of the executed operation |

</Callout>

<Accordions>
<Accordion title="Example">
<Tabs items={['TypeScript']}>
<Tab value="TypeScript">
```typescript
import { useOkto } from '@okto_web3/react-sdk';

function ExecuteOperation() {
const oktoClient = useOkto();

async function handleExecuteOperation(signedUserOp) {
try {
const txHash = await oktoClient.executeUserOp(signedUserOp);
console.log('Transaction hash:', txHash);
return txHash;
} catch (error:any) {
console.error('Error executing operation:', error);
}
}

return (
<button onClick={() => handleExecuteOperation(signedUserOp)}>
Execute Operation
</button>
);
}
```
</Tab>
</Tabs>
</Accordion>
</Accordions>

</div>

<Callout title="Note">
In case of errors, debug the error using the error code and refer to the [SDK errors and warnings](/docs/react-sdk/sdk-error-warnings) documentation for more details.
</Callout>
6 changes: 6 additions & 0 deletions content/docs/nextjs-sdk/(Account)/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title": "Account",
"pages": [
"userop-learn", "estimate", "signUserOp" , "executeUserOp"
]
}
79 changes: 79 additions & 0 deletions content/docs/nextjs-sdk/(Account)/signUserOp.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
title: Sign UserOp
description: Learn how to sign user operations using the Okto SDK.
full: false
---

import { TypeTable } from 'fumadocs-ui/components/type-table';
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
import { Callout } from 'fumadocs-ui/components/callout';
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
import { Icon as IIcon } from '@iconify/react';

The `signUserOp()` method is available on the OktoClient instance and is used to sign user operations before they can be executed on the blockchain. This method is essential for preparing transactions in a secure manner.

### Method Overview

| Methods | Description |
|---------|-------------|
| <sub><i>async</i></sub> [`oktoClient.signUserOp`](#sign-userop) | Sign a user operation |

<div className="method-box">

## Sign UserOp

<sub><i>async</i></sub> `oktoClient.signUserOp(userop: UserOp)` signs a user operation with the user's credentials.

### Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `userop` | [`UserOp`](/docs/react-sdk/technical-reference#models) | The user operation to be signed |

### Response

<Callout title="Success Response">

| Field Name | Type | Description |
|------------|------|-------------|
| `result` | [`Promise<UserOp>`](/docs/react-sdk/technical-reference#models) | Returns the signed user operation |

</Callout>

<Accordions>
<Accordion title="Example">
<Tabs items={['TypeScript']}>
<Tab value="TypeScript">
```typescript
import { useOkto } from '@okto_web3/react-sdk';

function SignOperation() {
const oktoClient = useOkto();

async function handleSignOperation(userOp) {
try {
const signedOp = await oktoClient.signUserOp(userOp);
console.log('Signed operation:', signedOp);
return signedOp;
} catch (error:any) {
console.error('Error signing operation:', error);
}
}

return (
<button onClick={() => handleSignOperation(userOp)}>
Sign Operation
</button>
);
}
```
</Tab>
</Tabs>
</Accordion>
</Accordions>

</div>

<Callout title="Note">
In case of errors, debug the error using the error code and refer to the [SDK errors and warnings](/docs/react-sdk/sdk-error-warnings) documentation for more details.
</Callout>
100 changes: 100 additions & 0 deletions content/docs/nextjs-sdk/(Explorer)/getAccount.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: Get Account
description: Learn how to get the account of a user using the Okto SDK.
full: false
---

import { TypeTable } from 'fumadocs-ui/components/type-table';
import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
import { Callout } from 'fumadocs-ui/components/callout';
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
import { Icon as IIcon } from '@iconify/react';

Okto SDK provides the `getAccount()` method to retrieve details of wallets connected to the current user's Okto account. This includes both embedded wallets created via Okto and external wallets connected by the user (e.g., MetaMask, Phantom).

### Method Overview

| Methods | Description |
|------------------------------------------------------|--------------------------------------|
| <sub><i>async</i></sub> [`getAccount`](#get-account) | Get the account of a user |

<div className="method-box">

## Get Account

<sub><i>async</i></sub> `getAccount()` retrieves the list of all wallets associated with the currently authenticated user.

In Okto, an **account** represents the user's identity in the Okto ecosystem, encompassing both embedded wallets seamlessly created by Okto and external wallets users choose to connect.

### Parameters

| Parameter | Type | Description |
|-------------|-----------------------------|----------------------------------------|
| `oktoClient` | [`OktoClient`](/docs/react-sdk/technical-reference#models) | Okto client |

### Response

<Callout title="Success Response">

| Field Name | Type | Description |
|------------|-----------------------|-----------------------------------------------|
| `result` | [`Promise<Wallet[]>`](/docs/react-sdk/technical-reference#models) | Returns the list of wallet of the user |

</Callout>

### Example

<Accordions>
<Accordion title="Usage">
<Tabs items={['Typescript']}>
<Tab value="Typescript">
```typescript
import { useOkto } from '@okto_web3/react-sdk';
import { getAccount } from '@okto_web3/react-sdk';

function Account() {
const oktoClient = useOkto();

async function fetchAccount() {
try {
const account = await getAccount(oktoClient);
console.log('Account data:', account);
} catch (error:any) {
console.error('Error fetching user account:', error);
}
}

return (
<button onClick={fetchAccount}>
Fetch User Account
</button>
);
}
```
</Tab>
</Tabs>
</Accordion>

<Accordion title="Success Response">
```json
{
"status": "success",
"data": [
{
"caip_id": "eip155:10",
"network_name": "OPTIMISM",
"address": "0x6698c56f99EaF4662cD70f974Cf787926e47781b",
"network_id": "f0620691-ce05-3d5c-94c7-1f2cf275c781",
"network_symbol": "OP"
}
]
}
```
</Accordion>
</Accordions>

</div>

<Callout title="Note">
In case of errors, debug the error using the error code and refer to the [SDK errors and warnings](/docs/react-sdk/sdk-error-warnings) documentation for more details.
</Callout>
Loading

0 comments on commit 7a776f3

Please # to comment.