Skip to content

Commit

Permalink
fix: add type (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
akasuv committed Sep 28, 2023
1 parent 90e0cac commit 88689b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
# Cyber App SDK
# CyberApp SDK

Create a CyberWallet app easily with Cyber App SDK.
Create a CyberAccount app easily with CyberApp SDK.

## Installation

```bash
npm install cyber-app-sdk
npm install @cyberlab/cyber-app-sdk
```

## Getting Started

### Connect to CyberWallet
### Connect to CyberAccount

```typescript
import { CyberApp } from "@cyberlab/cyber-app-sdk";

const app = new CyberApp({ name: "testapp" });
const { connected } = await app.start();
const app = new CyberApp({ name: "Your app name", icon: "Your app icon url" });
const cyberAccount = await app.start();

if (connected) {
console.log("Connected to CyberWallet");
if (cyberAccount) {
console.log("Connected to CyberAccount");
} else {
console.log("Connection to CyberWallet failed");
console.log("Connection to CyberAccount failed");
}
```

### Send a transaction
### Send a transaction on Optimism

```typescript
async function sendTransaction() {
const res = await app?.cyberWallet?.optimism
const res = await app?.cyberwallet?.optimism
.sendTransaction({
to: "0x1234134234",
value: "0.000000000000000001",
Expand All @@ -38,3 +38,9 @@ async function sendTransaction() {
.catch((err: any) => console.log({ err }));
}
```

## Run your local app in CyberAccount Sandbox

1. Start your local app server
2. Go to [CyberAccount Sandbox](http://wallet-sandbox.cyber.co/?_vercel_share=9mH7nlXjAUEU238zCzxJ3fW0TvC2nsX5)
3. Input your app server url
7 changes: 4 additions & 3 deletions src/CyberApp.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CyberAccount from "./CyberAccount";
import CyberWallet from "./CyberWallet";
import Messenger from "./Messenger";
import type { AppInfo } from "./types";
Expand All @@ -20,8 +21,8 @@ class CyberApp {
});
}

public async start() {
return await this.connect();
public async start(): Promise<CyberAccount> {
return (await this.connect()) as CyberAccount;
}

public connect() {
Expand All @@ -38,7 +39,7 @@ class CyberApp {
this.cyberWallet.setCyberAccount(
message.event.data?.data?.cyberAccount,
);
resolve({ connected: true });
resolve(message.event.data?.data?.cyberAccount);
} else {
if (message.event.data?.error) {
reject(message.event.data?.error);
Expand Down

0 comments on commit 88689b6

Please sign in to comment.