Skip to content

Commit 3f83f99

Browse files
committed
style: format file w/ prettier
1 parent 70c8131 commit 3f83f99

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

src/graphql/scalars/ethBigInt.ts

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,37 @@
1-
import {GraphQLScalarType} from "graphql/type/index.js";
2-
import {Kind} from "graphql/language/index.js";
1+
import { GraphQLScalarType } from "graphql/type/index.js";
2+
import { Kind } from "graphql/language/index.js";
33

44
export const EthBigInt = new GraphQLScalarType({
5-
name: "EthBigInt",
6-
description: "Handles uint256 bigint values stored in DB",
7-
serialize(value: unknown): string {
8-
// Check type of value
9-
if (typeof value !== "bigint" && typeof value !== "number" && typeof value !== "string") {
10-
throw new Error("EthBigInt can only serialize BigInt values");
11-
}
12-
return BigInt(value).toString(); // Value sent to client
13-
},
14-
parseValue(value: unknown): bigint {
15-
// Check type of value bigint | boolean | number | string
16-
if (typeof value !== "string" && typeof value !== "bigint" && typeof value !== "number" && typeof value !== "boolean") {
17-
throw new Error("EthBigInt can only parse string values");
18-
}
19-
return BigInt(value); // Value from client input variables
20-
},
21-
parseLiteral(ast): bigint {
22-
// Check type of value
23-
if (ast.kind !== Kind.STRING) {
24-
throw new Error("ObjectIdScalar can only parse string values");
25-
}
26-
return BigInt(ast.value); // Value from client query
27-
},
28-
});
5+
name: "EthBigInt",
6+
description: "Handles uint256 bigint values stored in DB",
7+
serialize(value: unknown): string {
8+
// Check type of value
9+
if (
10+
typeof value !== "bigint" &&
11+
typeof value !== "number" &&
12+
typeof value !== "string"
13+
) {
14+
throw new Error("EthBigInt can only serialize BigInt values");
15+
}
16+
return BigInt(value).toString(); // Value sent to client
17+
},
18+
parseValue(value: unknown): bigint {
19+
// Check type of value bigint | boolean | number | string
20+
if (
21+
typeof value !== "string" &&
22+
typeof value !== "bigint" &&
23+
typeof value !== "number" &&
24+
typeof value !== "boolean"
25+
) {
26+
throw new Error("EthBigInt can only parse string values");
27+
}
28+
return BigInt(value); // Value from client input variables
29+
},
30+
parseLiteral(ast): bigint {
31+
// Check type of value
32+
if (ast.kind !== Kind.STRING) {
33+
throw new Error("ObjectIdScalar can only parse string values");
34+
}
35+
return BigInt(ast.value); // Value from client query
36+
},
37+
});

0 commit comments

Comments
 (0)