Skip to content

Commit

Permalink
sync latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
0xaptosj committed Sep 23, 2024
1 parent ad4e09f commit a4fc968
Show file tree
Hide file tree
Showing 130 changed files with 1,482 additions and 1,108 deletions.
File renamed without changes.
3 changes: 0 additions & 3 deletions templates/indexer-template/.gitignore

This file was deleted.

201 changes: 0 additions & 201 deletions templates/indexer-template/LICENSE

This file was deleted.

71 changes: 64 additions & 7 deletions templates/indexer-template/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,67 @@
# A template to build a full stack app on Aptos
# Aptos full stack template UI

Please read each directory's readme carefully to understand how to use the template.
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

This template is an alternative template to [CAD (create-aptos-dapp)](https://aptos.dev/en/build/create-aptos-dapp). Some notable differences are:
## Local development

- This template uses more experimental features, such as [indexer-sdk](https://github.com/aptos-labs/aptos-indexer-processor-sdk).
- This template uses Next.js instead of Vite.
- This templates doesn't support Windows.
- CAD provides more production ready templates that have been audited like token minting, NFT minting, etc.
This template uses `@neondatabase/serverless` to connect to a Postgres database. When testing locally, you can connect to a dev branch of neon DB.

## Create a read only user in DB

Frontend should only read from the DB, the indexer is the only one that writes to the DB. So, create a read only user in the DB for frontend to use prevent any accidental write operations.

```sql
-- Create a readonly user
-- Please don't use any special characters in the password to avoid db sdk give invalid connection string error
CREATE USER readonly WITH PASSWORD 'strong_password'
-- Grant readonly user read access to all tables in public schema
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
-- Grant readonly user read access to all future tables in public schema
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly;
```

Some useful SQLs to check the user and schema:

```sql
-- Get all users
SELECT * FROM pg_user;
-- Get all schemas
SELECT schema_name FROM information_schema.schemata;
```

Then fill the `POSTGRES_URL` in `.env` file with the readonly user.

## Getting Started

First, run the development server:

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.

This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.

## Learn More

To learn more about Next.js, take a look at the following resources:

- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.

You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!

## Deploy on Vercel

The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.

Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
34 changes: 34 additions & 0 deletions templates/indexer-template/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Aptos related files
.aptos
.env
contract/build

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
build
dist-ssr
*.local
package-lock.json
pnpm-lock.yaml

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

.next
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ authors = []
[addresses]
message_board_addr = "_"

[dev-addresses]
message_board_addr = "0x999"

[dependencies]
AptosFramework = { git = "https://github.com/aptos-labs/aptos-core.git", rev = "mainnet", subdir = "aptos-move/framework/aptos-framework" }

Expand Down
3 changes: 0 additions & 3 deletions templates/indexer-template/contracts/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions templates/indexer-template/contracts/README.MD

This file was deleted.

15 changes: 0 additions & 15 deletions templates/indexer-template/contracts/message-board/README.MD

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a4fc968

Please sign in to comment.