Skip to content

Commit e0dc722

Browse files
fix(api): contract api (#1322)
1 parent 9a1825d commit e0dc722

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

apps/api/src/services/v3/accounts/contract.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ import { responseHandler } from '#middlewares/response';
2020
import type { RequestValidator } from '#middlewares/validate';
2121
import sql from '#sql/accounts';
2222

23+
type Deployment = {
24+
block_timestamp: string;
25+
receipt_id: string;
26+
};
27+
2328
const contract = responseHandler(
2429
response.contract,
2530
async (req: RequestValidator<ContractReq>) => {
@@ -40,9 +45,7 @@ const deployments = responseHandler(
4045

4146
const first = await rollingWindow(
4247
(start, end) => {
43-
return dbContract.oneOrNone<
44-
Pick<ContractDeployment, 'block_timestamp' | 'receipt_id'>
45-
>(sql.contracts.deployments, {
48+
return dbContract.oneOrNone<Deployment>(sql.contracts.deployments, {
4649
account,
4750
end,
4851
order: 'ASC',
@@ -54,9 +57,7 @@ const deployments = responseHandler(
5457

5558
const last = await rollingWindow(
5659
(start, end) => {
57-
return dbContract.oneOrNone<
58-
Pick<ContractDeployment, 'block_timestamp' | 'receipt_id'>
59-
>(sql.contracts.deployments, {
60+
return dbContract.oneOrNone<Deployment>(sql.contracts.deployments, {
6061
account,
6162
end,
6263
order: 'DESC',
@@ -82,13 +83,7 @@ const deployments = responseHandler(
8283
});
8384
const unionQuery = queries.join('\nUNION ALL\n');
8485

85-
const data =
86-
await dbBase.manyOrNone<
87-
Pick<
88-
ContractDeployment,
89-
'block' | 'predecessor_account_id' | 'transaction_hash'
90-
>
91-
>(unionQuery);
86+
const data = await dbBase.manyOrNone<ContractDeployment>(unionQuery);
9287

9388
return { data };
9489
},

packages/nb-schemas/src/accounts/response.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ const block = v.object({
4040

4141
const deployment = v.object({
4242
block,
43-
block_timestamp: v.string(),
4443
predecessor_account_id: v.string(),
45-
receipt_id: v.string(),
4644
transaction_hash: v.string(),
4745
});
4846

@@ -68,6 +66,7 @@ export type AccountBalance = v.InferOutput<typeof balance>;
6866
export type Contract = v.InferOutput<typeof contract>;
6967
export type ContractDeployment = v.InferOutput<typeof deployment>;
7068
export type ContractSchema = v.InferOutput<typeof schema>;
69+
export type ContractAction = v.InferOutput<typeof action>;
7170

7271
export type AccountRes = v.InferOutput<typeof accountResponse>;
7372
export type AccountBalanceRes = v.InferOutput<typeof balanceResponse>;

0 commit comments

Comments
 (0)