Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add wallet entity #2264

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add wallet entity #2264

wants to merge 4 commits into from

Conversation

jmealy
Copy link
Contributor

@jmealy jmealy commented Jan 15, 2025

Summary

Adds a new entity for Wallet. Each entry represents a signer wallet that can be used to sign in for a User.

Changes

  • Creates Wallet entity
  • Creates walletBuilder

@jmealy jmealy requested a review from a team as a code owner January 15, 2025 14:14
@jmealy jmealy marked this pull request as draft January 15, 2025 14:15
@jmealy jmealy changed the base branch from main to add-users-entity January 15, 2025 14:15
Base automatically changed from add-users-entity to main January 15, 2025 14:23
@jmealy jmealy force-pushed the add-wallet-entity branch from eafbd44 to 6807c42 Compare January 15, 2025 14:39
@jmealy jmealy force-pushed the add-wallet-entity branch from 6807c42 to cec4604 Compare January 15, 2025 14:44
@jmealy jmealy marked this pull request as ready for review January 15, 2025 14:45
Comment on lines 25 to 26
@PrimaryGeneratedColumn('uuid')
id!: UUID;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we want to use a UUID as the primary key? Are we going to expose this value? I'd suggest using an auto-incrementing value if not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to auto-incrementing id 11fb705

@ManyToOne(() => User, (user) => user.id, {
onDelete: 'CASCADE',
})
user_id!: UUID;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the above, this might need changing in accordance with #2262 (comment).

Copy link
Contributor Author

@jmealy jmealy Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do auto incrementing 👍 Just to be aware, with auto incrementing IDs we would expose how many accounts have been created, but I'm not sure if this matters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use both integer and UUID, you can make the primary key an integer and add a unique uuid column for cases where the ID shouldn’t be exposed. For foreign keys, stick to using the integer field instead of the UUID, since UUIDs are bigger and can make indexes larger, which will slow things down.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed User to use auto incrementing ID as well: 11fb705

Comment on lines 48 to 59
@Column({
type: 'timestamp with time zone',
default: () => 'CURRENT_TIMESTAMP',
})
created_at!: Date;

@Column({
type: 'timestamp with time zone',
default: () => 'CURRENT_TIMESTAMP',
onUpdate: 'CURRENT_TIMESTAMP',
})
updated_at!: Date;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@jmealy jmealy Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to write the queries manually, but you can reuse the ones from the notification by simply updating the names.

my understanding is that this will be done when we are generating the migrations. So here I've just removed onUpdate: 'CURRENT_TIMESTAMP', since it doesn't do anything and the rest will be done later. lmk if that's correct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmealy Since PostgreSQL does not have a direct ON UPDATE clause for columns, we should add a Trigger for it. Please refer to the Notification migration, as a similar approach is used there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes understood 👍 but this PR is just for the entity, not the migration, so I have nowhere to add it yet. I can add it after this PR is merged and and a migration is generated

@jmealy jmealy requested a review from PooyaRaki January 16, 2025 13:58
@JoinColumn({ name: 'user_id' })
user!: User;

@Column({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we’ll be searching for wallets by their address. If that’s the case, I’d index this column to improve search performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@usame-algan usame-algan requested a review from PooyaRaki January 20, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants