Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit a074a52

Browse files
committed
refactor: move alias ownership check into SQL query
1 parent 311c88d commit a074a52

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/writer/alias.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ export async function verify(message): Promise<any> {
1414
return Promise.reject('alias cannot be the same as the address');
1515
}
1616

17-
const [existing] = await db.queryAsync('SELECT address FROM aliases WHERE alias = ? LIMIT 1', [
18-
msg.payload.alias
19-
]);
20-
if (existing && existing.address.toLowerCase() !== message.address.toLowerCase()) {
17+
const [existing] = await db.queryAsync(
18+
'SELECT address FROM aliases WHERE alias = ? AND address != ? LIMIT 1',
19+
[msg.payload.alias, message.address]
20+
);
21+
if (existing) {
2122
return Promise.reject('alias is already linked to another address');
2223
}
2324

0 commit comments

Comments
 (0)