Skip to content

Commit 73df136

Browse files
authored
oko_pg_interface: rename some old "ewallet-" names as "oko-"
* oko_pg_interface: rename ewallet to oko (tables, types, directories) * oko_pg_interface: update import paths and SQL for oko rename * admin_api: update import paths for oko rename * social_login_api: update import paths for oko rename * tss_api: update import paths for oko rename * user_dashboard_api: rename test db ewallet_dev to oko_dev * docs_web: update table names for oko rename
1 parent 0f4937a commit 73df136

File tree

26 files changed

+94
-58
lines changed

26 files changed

+94
-58
lines changed

apps/docs_web/docs/v0/lifecycle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ For new users, distributed key shares are created:
7777
- Stores encrypted shares in key share nodes
7878
7979
2. Database Updates:
80-
- ewallet_wallets table: new entry with public key
80+
- oko_wallets table: new entry with public key
8181
- wallet_ks_nodes table: key share node assignments
82-
- ewallet_users table: user account information
82+
- oko_users table: user account information
8383
```
8484

8585
**User Experience:**

backend/admin_api/src/api/wallet/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type {
77
import {
88
getAllWallets,
99
getWalletsCount,
10-
} from "@oko-wallet/oko-pg-interface/ewallet_wallets";
10+
} from "@oko-wallet/oko-pg-interface/oko_wallets";
1111

1212
export async function getWalletList(
1313
db: Pool,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { Knex } from "knex";
2+
3+
export async function up(knex: Knex): Promise<void> {
4+
await knex.schema.renameTable("ewallet_users", "oko_users");
5+
await knex.schema.renameTable("ewallet_wallets", "oko_wallets");
6+
7+
await knex.raw(`
8+
ALTER TABLE oko_users RENAME CONSTRAINT ewallet_users_pkey TO oko_users_pkey;
9+
ALTER TABLE oko_users RENAME CONSTRAINT ewallet_users_email_auth_type_key TO oko_users_email_auth_type_key;
10+
ALTER TABLE oko_wallets RENAME CONSTRAINT ewallet_wallets_pkey TO oko_wallets_pkey;
11+
ALTER TABLE oko_wallets RENAME CONSTRAINT ewallet_wallets_public_key_key TO oko_wallets_public_key_key;
12+
`);
13+
14+
await knex.raw(`
15+
ALTER INDEX idx_ewallet_wallets_created_at RENAME TO idx_oko_wallets_created_at;
16+
ALTER INDEX idx_ewallet_wallets_user_id_curve_type_status RENAME TO idx_oko_wallets_user_id_curve_type_status;
17+
`);
18+
}
19+
20+
export async function down(knex: Knex): Promise<void> {
21+
await knex.raw(`
22+
ALTER INDEX idx_oko_wallets_created_at RENAME TO idx_ewallet_wallets_created_at;
23+
ALTER INDEX idx_oko_wallets_user_id_curve_type_status RENAME TO idx_ewallet_wallets_user_id_curve_type_status;
24+
`);
25+
26+
await knex.raw(`
27+
ALTER TABLE oko_users RENAME CONSTRAINT oko_users_pkey TO ewallet_users_pkey;
28+
ALTER TABLE oko_users RENAME CONSTRAINT oko_users_email_auth_type_key TO ewallet_users_email_auth_type_key;
29+
ALTER TABLE oko_wallets RENAME CONSTRAINT oko_wallets_pkey TO ewallet_wallets_pkey;
30+
ALTER TABLE oko_wallets RENAME CONSTRAINT oko_wallets_public_key_key TO ewallet_wallets_public_key_key;
31+
`);
32+
33+
await knex.schema.renameTable("oko_users", "ewallet_users");
34+
await knex.schema.renameTable("oko_wallets", "ewallet_wallets");
35+
}
36+

backend/oko_pg_interface/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"./customers": "./src/customers/index.ts",
2020
"./email_verifications": "./src/email_verifications/index.ts",
2121
"./email_sent_logs": "./src/email_sent_logs/index.ts",
22-
"./ewallet_users": "./src/ewallet_users/index.ts",
23-
"./ewallet_wallets": "./src/ewallet_wallets/index.ts",
22+
"./oko_users": "./src/oko_users/index.ts",
23+
"./oko_wallets": "./src/oko_wallets/index.ts",
2424
"./tss": "./src/tss/index.ts",
2525
"./tss_activate": "./src/tss_activate/index.ts",
2626
"./key_share_node_meta": "./src/key_share_node_meta/index.ts",

backend/oko_pg_interface/scripts/seed_backup/data/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
CustomerAndCTDUserWithPasswordHash,
77
PasswordHash,
88
} from "@oko-wallet/oko-types/ct_dashboard";
9-
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
9+
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
1010
import type { KeyShareNodeMeta } from "@oko-wallet/oko-types/key_share_node_meta";
1111
import type { TssActivationSetting } from "@oko-wallet-types/tss_activate";
1212

@@ -30,7 +30,7 @@ export function createKeyShareNodeMeta(): KeyShareNodeMeta {
3030
};
3131
}
3232

33-
export async function createAdmin(): Promise<EWalletAdminUser> {
33+
export async function createAdmin(): Promise<OkoAdminUser> {
3434
return {
3535
user_id: ADMIN_USER_ID,
3636
email: ADMIN_EMAIL,

backend/oko_pg_interface/scripts/seed_backup/data/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
CustomerDashboardUser,
44
PasswordHash,
55
} from "@oko-wallet/oko-types/ct_dashboard";
6-
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
6+
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
77

88
import {
99
createAdmin,
@@ -19,7 +19,7 @@ import type { KeyShareNodeMeta } from "@oko-wallet-types/key_share_node_meta";
1919
import type { TssActivationSetting } from "@oko-wallet-types/tss_activate";
2020

2121
export interface SeedData {
22-
admin: EWalletAdminUser;
22+
admin: OkoAdminUser;
2323
customer: Customer;
2424
customerDashboardUser: CustomerDashboardUser & PasswordHash;
2525
apiKeys: { customer_id: string; hashed_key: string }[];

backend/oko_pg_interface/seeds/data/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
CustomerAndCTDUserWithPasswordHash,
77
PasswordHash,
88
} from "@oko-wallet/oko-types/ct_dashboard";
9-
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
9+
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
1010
import type { KeyShareNodeMeta } from "@oko-wallet/oko-types/key_share_node_meta";
1111
import type { TssActivationSetting } from "@oko-wallet-types/tss_activate";
1212

@@ -30,7 +30,7 @@ export function createKeyShareNodeMeta(): KeyShareNodeMeta {
3030
};
3131
}
3232

33-
export async function createAdmin(): Promise<EWalletAdminUser> {
33+
export async function createAdmin(): Promise<OkoAdminUser> {
3434
return {
3535
user_id: ADMIN_USER_ID,
3636
email: ADMIN_EMAIL,

backend/oko_pg_interface/seeds/initial_seed.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export async function seed(knex: Knex): Promise<void> {
2323
await knex("ks_node_health_checks").del();
2424
await knex("key_share_nodes").del();
2525
await knex("key_share_node_meta").del();
26-
await knex("ewallet_wallets").del();
27-
await knex("ewallet_users").del();
26+
await knex("oko_wallets").del();
27+
await knex("oko_users").del();
2828
await knex("email_verifications").del();
2929
await knex("customer_dashboard_users").del();
3030
await knex("api_keys").del();

backend/oko_pg_interface/src/admin_users/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Pool, type PoolClient } from "pg";
2-
import type { EWalletAdminUser } from "@oko-wallet/oko-types/admin";
2+
import type { OkoAdminUser } from "@oko-wallet/oko-types/admin";
33
import type { Result } from "@oko-wallet/stdlib-js";
44

55
export async function createAdmin(
66
db: Pool | PoolClient,
7-
adminUser: EWalletAdminUser,
7+
adminUser: OkoAdminUser,
88
): Promise<Result<string, string>> {
99
const query = `
1010
INSERT INTO admin_users (
@@ -27,7 +27,7 @@ RETURNING user_id
2727
];
2828

2929
try {
30-
const result = await db.query<EWalletAdminUser>(query, values);
30+
const result = await db.query<OkoAdminUser>(query, values);
3131

3232
const row = result.rows[0];
3333
if (!row) {
@@ -49,7 +49,7 @@ RETURNING user_id
4949
export async function getAdminByEmail(
5050
db: Pool,
5151
email: string,
52-
): Promise<Result<EWalletAdminUser | null, string>> {
52+
): Promise<Result<OkoAdminUser | null, string>> {
5353
const query = `
5454
SELECT *
5555
FROM admin_users
@@ -58,7 +58,7 @@ LIMIT 1
5858
`;
5959

6060
try {
61-
const result = await db.query<EWalletAdminUser>(query, [email]);
61+
const result = await db.query<OkoAdminUser>(query, [email]);
6262
return {
6363
success: true,
6464
data: result.rows.length > 0 ? result.rows[0] : null,
@@ -74,7 +74,7 @@ LIMIT 1
7474
export async function getAdminById(
7575
db: Pool,
7676
adminId: string,
77-
): Promise<Result<EWalletAdminUser | null, string>> {
77+
): Promise<Result<OkoAdminUser | null, string>> {
7878
const query = `
7979
SELECT *
8080
FROM admin_users
@@ -83,7 +83,7 @@ LIMIT 1
8383
`;
8484

8585
try {
86-
const result = await db.query<EWalletAdminUser>(query, [adminId]);
86+
const result = await db.query<OkoAdminUser>(query, [adminId]);
8787
return {
8888
success: true,
8989
data: result.rows.length > 0 ? result.rows[0] : null,

backend/oko_pg_interface/src/ewallet_users/index.ts renamed to backend/oko_pg_interface/src/oko_users/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function createUser(
1111
): Promise<Result<User, string>> {
1212
try {
1313
const query = `
14-
INSERT INTO ewallet_users (
14+
INSERT INTO oko_users (
1515
user_id, email, auth_type
1616
) VALUES (
1717
$1, $2, $3
@@ -50,7 +50,7 @@ export async function getUserByEmailAndAuthType(
5050
try {
5151
const query = `
5252
SELECT *
53-
FROM ewallet_users
53+
FROM oko_users
5454
WHERE email = $1 AND auth_type = $2
5555
LIMIT 1
5656
`;

0 commit comments

Comments
 (0)