Skip to content

Commit 9868634

Browse files
committed
fix: uint8 parsing
- for some reason, kysely database reads return a string when it's supposed to be a uint8 or number. parsing them manually fixes the problem, but to ensure no other bugs exist we should figure out how to make it parse them as numbers.
1 parent 374f887 commit 9868634

File tree

3 files changed

+39
-10
lines changed

3 files changed

+39
-10
lines changed

src/services/database/entities/BlueprintsEntityService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ export class BlueprintsService {
8787
.where("blueprint_id", "=", blueprintId)
8888
.innerJoin("users", "blueprint_admins.user_id", "users.id")
8989
.selectAll("users")
90-
.execute();
90+
.execute()
91+
.then((res) =>
92+
res.map((admin) => ({
93+
...admin,
94+
// TODO: Investigate why chain_id is returned as a string
95+
chain_id: Number(admin.chain_id),
96+
})),
97+
);
9198
}
9299

93100
/**

src/services/database/entities/MarketplaceOrdersEntityService.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,21 @@ export class MarketplaceOrdersService {
130130
throw new Error("Address and chain ID are required");
131131
}
132132

133-
return this.dbService
134-
.getConnection()
135-
.selectFrom("marketplace_order_nonces")
136-
.selectAll()
137-
.where("address", "=", nonce.address)
138-
.where("chain_id", "=", nonce.chain_id)
139-
.executeTakeFirst();
133+
return (
134+
this.dbService
135+
.getConnection()
136+
.selectFrom("marketplace_order_nonces")
137+
.selectAll()
138+
.where("address", "=", nonce.address)
139+
.where("chain_id", "=", nonce.chain_id)
140+
.executeTakeFirst()
141+
// TODO: Investigate why chain_id and nonce_counter are returned as strings
142+
.then((res) => ({
143+
...res,
144+
chain_id: Number(res?.chain_id),
145+
nonce_counter: Number(res?.nonce_counter),
146+
}))
147+
);
140148
}
141149

142150
/**
@@ -292,7 +300,14 @@ export class MarketplaceOrdersService {
292300
// @ts-expect-error Typing issue with provider
293301
EvmClientFactory.createEthersClient(chainId),
294302
);
295-
const validationResults = await hec.checkOrdersValidity(matchingOrders);
303+
console.log("matchingOrders", matchingOrders);
304+
const validationResults = await hec.checkOrdersValidity(
305+
matchingOrders.map((order) => ({
306+
...order,
307+
chainId: Number(order.chainId),
308+
})),
309+
);
310+
console.log("validationResults", validationResults);
296311

297312
// filter all orders that have changed validity or validator codes
298313
const _changedOrders = validationResults

src/services/database/entities/UsersEntityService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ export class UsersService {
2323
}
2424

2525
async getUsers(args: GetUsersArgs) {
26-
return this.entityService.getMany(args);
26+
return this.entityService.getMany(args).then((res) => ({
27+
...res,
28+
data: res.data.map((user) => ({
29+
...user,
30+
// TODO: Investigate why chain_id is returned as a string
31+
chain_id: Number(user.chain_id),
32+
})),
33+
}));
2734
}
2835

2936
async getUser(args: GetUsersArgs) {

0 commit comments

Comments
 (0)