-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SQLite, account creation, and account fetching (#16)
- Loading branch information
Showing
21 changed files
with
378 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# facades | ||
|
||
Facades use the `data-facade` package to provide a `tanstack/react-query` interface between the wallet code in the `data` folder and the Expo frontend in the `app` folder. | ||
|
||
The facade routes are intended to be similar to the [Iron Fish RPC routes](https://github.com/iron-fish/ironfish/tree/master/ironfish/src/rpc/routes). Our goal is that in the future, we could implement a facade that connects directly to an Iron Fish node with minimal changes to the frontend code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { f } from "data-facade"; | ||
import { z } from "zod"; | ||
import { AccountsMethods } from "./types"; | ||
|
||
let ACCOUNTS = [ | ||
{ id: 0, name: "alice", viewOnlyAccount: "alice" }, | ||
{ id: 1, name: "bob", viewOnlyAccount: "bob"}, | ||
{ id: 2, name: "carol", viewOnlyAccount: "carol"} | ||
]; | ||
|
||
async function getAccounts(limit: number) { | ||
await new Promise((resolve) => setTimeout(resolve, 1000)); | ||
return ACCOUNTS.slice(0, limit); | ||
} | ||
|
||
export const accountsHandlers = f.facade<AccountsMethods>({ | ||
getAccounts: f.handler.query(async () => { | ||
const accounts = await getAccounts(ACCOUNTS.length); | ||
console.log("getAccounts", accounts); | ||
return accounts; | ||
}), | ||
createAccount: f.handler | ||
.input( | ||
z.object({ | ||
name: z.string(), | ||
}), | ||
) | ||
.mutation(async ({ name }) => { | ||
const existingId = ACCOUNTS.at(-1)?.id | ||
if (existingId === undefined) { | ||
throw new Error("No accounts found"); | ||
} | ||
const account = { id: existingId + 1, name, viewOnlyAccount: name } | ||
console.log("createAccount", account); | ||
ACCOUNTS.push(account); | ||
return account; | ||
}), | ||
}); |
Oops, something went wrong.