Skip to content

Commit 92d38fe

Browse files
rooch: add sqlite support for dev env.
Signed-off-by: ZHANG, HENGMING <22887031+ghpZ54K8ZRwU62zGVSePPs97yAv9swuAY0mVDR4@users.noreply.github.com>
1 parent 583edc2 commit 92d38fe

File tree

6 files changed

+81
-16
lines changed

6 files changed

+81
-16
lines changed

.env.sample

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ POSTGRES_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\
1818
# Prisma postgres config
1919
DATABASE_URL="postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres_db:5432/${POSTGRES_DB}"
2020

21+
# Sqlite config
22+
SQLITE_PATH=sqlite.db
23+
24+
# Prisma sqlite config
25+
DATABASE_URL_DEV="file:${SQLITE_PATH}"
26+
2127
# Optionals
2228
SENTRY_DSN=""
2329
ECDSA_PRIVATE_KEY="" # for verity analysis.
2430

2531
# Integrations
2632
X_BEARER_TOKEN=""
2733

28-
OPEN_AI_TOKEN=""
34+
OPEN_AI_TOKEN=""
35+
36+
ALBY_ACCESS_TOKEN=""

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,11 @@ temp*
126126

127127
# else
128128
.script
129+
deno.lock
129130

130131
# Prisma
131-
prisma/.db
132-
prisma/.db*
133-
orchestrator/prisma/.db
134-
orchestrator/prisma/.db*
132+
orchestrator/prisma-dev/*.db
133+
orchestrator/prisma-dev/*.db*
135134
.infisical.json
136135
.aptos
137136
migration_lock.toml

docs/ROOCH.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pnpm prisma:deploy
7979
**In Development (for SQLite):**
8080

8181
```bash
82-
pnpm clean:db
82+
pnpm clean:db:dev
8383
pnpm prisma:generate:dev
8484
pnpm prisma:deploy:dev
8585
```
@@ -100,7 +100,7 @@ rooch account export --address <Rooch Address>
100100

101101

102102
To connect to the local Rooch node, set `ROOCH_CHAIN_ID` to `"localnet"`.
103-
Otherwise, connect to testNet by setting `ROOCH_CHAIN_ID` to `"testnet"`, or to TestNet by setting `ROOCH_CHAIN_ID` to `"testnet"`.
103+
Otherwise, connect to DevNet by setting `ROOCH_CHAIN_ID` to `"devnet"`, to TestNet by setting `ROOCH_CHAIN_ID` to `"testnet"`, or to MainNet by setting `ROOCH_CHAIN_ID` to `"mainnet"`.
104104
Ensure that `ROOCH_ORACLE_ADDRESS` is set to the address of the deployed module, e.g., `"0x85859e45551846d9ab8651bb0b6f6e1740c9d758cfda05cfc39d49e2a604d783"`.
105105

106106
#### Step 7: Register supported URL
@@ -109,19 +109,19 @@ Additional steps for managing supported orchestrator URL
109109
- To add URL
110110

111111
```bash
112-
rooch move run --function 0xf1290fb0e7e1de7e92e616209fb628970232e85c4c1a264858ff35092e1be231::registry::add_supported_url --sender-account 0x694cbe655b126e9e6a997e86aaab39e538abf30a8c78669ce23a98740b47b65d --args 'string:https://api.openai.com/v1/chat/completions' --args 'u256:50000' --args 'u64:40' --args 'u256:4000' --args 'u256:5000'
112+
rooch move run --function <contract_address>::registry::add_supported_url --sender-account <orchestrator_address> --args 'string:https://api.openai.com/v1/chat/completions' --args 'u256:50000' --args 'u64:40' --args 'u256:4000' --args 'u256:5000'
113113
```
114114

115115
- to remove URLs
116116

117117
```bash
118-
rooch move run --function 0xf1290fb0e7e1de7e92e616209fb628970232e85c4c1a264858ff35092e1be231::registry::remove_supported_url --sender-account <orchestrator_address> --args 'string:https://api.twitter.com/2/users/'
118+
rooch move run --function <contract_address>::registry::remove_supported_url --sender-account <orchestrator_address> --args 'string:https://api.openai.com/v1/chat/completions'
119119
```
120120

121-
- To view supported URLS
121+
- To view supported URLs
122122

123123
```bash
124-
rooch move view --function 0xf1290fb0e7e1de7e92e616209fb628970232e85c4c1a264858ff35092e1be231::registry::get_supported_urls --args 'address:0x694cbe655b126e9e6a997e86aaab39e538abf30a8c78669ce23a98740b47b65d'
124+
rooch move view --function <contract_address>::registry::get_supported_urls --args 'address:<orchestrator_address>'
125125
```
126126

127127

orchestrator/prisma-dev/index.ts

Whitespace-only changes.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// This is your Prisma schema file,
2+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
3+
4+
generator client {
5+
provider = "prisma-client-js"
6+
}
7+
8+
datasource db {
9+
provider = "sqlite"
10+
url = env("DATABASE_URL_DEV")
11+
}
12+
13+
model Events{
14+
id String @id @default(cuid())
15+
eventHandleId String
16+
eventSeq BigInt
17+
eventType String
18+
eventData String
19+
eventIndex String
20+
decoded_event_data String //JSON String
21+
chain String @default("ROOCH-testnet")
22+
23+
status Int
24+
retries Int
25+
response String?
26+
indexedAt DateTime @default(now())
27+
updateAt DateTime @updatedAt
28+
29+
@@index([eventHandleId, eventSeq,chain])
30+
}
31+
32+
model Keeper{
33+
id String @id @default(cuid())
34+
chain String @default("ROOCH-testnet")
35+
module String
36+
privateKey String
37+
38+
createdAt DateTime @default(now())
39+
updateAt DateTime @updatedAt
40+
41+
@@unique([chain, module])
42+
43+
}

package.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
"node": ">=18"
88
},
99
"type": "module",
10-
"keywords": ["web3", "crypto", "blockchain", "move", "verity", "smart-contracts"],
10+
"keywords": [
11+
"web3",
12+
"crypto",
13+
"blockchain",
14+
"move",
15+
"verity",
16+
"smart-contracts"
17+
],
1118
"author": "Ryan Soury <[email protected]>",
1219
"license": "LGPL-2.1",
1320
"bugs": {
@@ -21,14 +28,18 @@
2128
"lint": "biome check orchestrator/src/",
2229
"lint:fix": "biome check orchestrator/src/ --fix",
2330
"clean": "del dist",
24-
"clean:db": "del ./orchestrator/prisma/.db*",
31+
"clean:db": "del ./orchestrator/prisma/*.db*",
32+
"clean:db:dev": "del ./orchestrator/prisma-dev/*.db*",
2533
"prepare": "husky",
2634
"format": "biome format orchestrator/src/ --fix",
2735
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org usherlabs --project verity-move-oracles ./dist && sentry-cli sourcemaps upload --org usherlabs --project verity-move-oracles ./dist",
2836
"test": "jest --runInBand ",
2937
"prisma:generate": "prisma generate --schema=./orchestrator/prisma/schema.prisma",
38+
"prisma:generate:dev": "prisma generate --schema=./orchestrator/prisma-dev/schema.prisma",
3039
"prisma:deploy": "prisma migrate deploy --schema=./orchestrator/prisma/schema.prisma",
31-
"prisma:studio": "prisma studio --schema=./orchestrator/prisma/schema.prisma"
40+
"prisma:deploy:dev": "prisma migrate deploy --schema=./orchestrator/prisma-dev/schema.prisma",
41+
"prisma:studio": "prisma studio --schema=./orchestrator/prisma/schema.prisma",
42+
"prisma:studio:dev": "prisma studio --schema=./orchestrator/prisma-dev/schema.prisma"
3243
},
3344
"devDependencies": {
3445
"@biomejs/biome": "^1.8.3",
@@ -65,13 +76,17 @@
6576
"tslog": "^4.9.3"
6677
},
6778
"lint-staged": {
68-
"*.{js,ts,cjs,mjs,d.cts,d.mts,json,jsonc}": ["biome check --apply --no-errors-on-unmatched"]
79+
"*.{js,ts,cjs,mjs,d.cts,d.mts,json,jsonc}": [
80+
"biome check --apply --no-errors-on-unmatched"
81+
]
6982
},
7083
"prisma": {
7184
"schema": "orchestrator/prisma/schema.prisma"
7285
},
7386
"tsup": {
74-
"entry": ["./orchestrator/src"],
87+
"entry": [
88+
"./orchestrator/src"
89+
],
7590
"splitting": false,
7691
"sourcemap": true,
7792
"clean": true

0 commit comments

Comments
 (0)