11import { Static , Type } from "@sinclair/typebox" ;
2+ import { ethers } from "ethers" ;
23import { FastifyInstance } from "fastify" ;
34import { StatusCodes } from "http-status-codes" ;
45import { getWallet } from "../../../utils/cache/getWallet" ;
@@ -7,6 +8,7 @@ import { walletAuthSchema } from "../../schemas/wallet";
78
89const BodySchema = Type . Object ( {
910 message : Type . String ( ) ,
11+ isBytes : Type . Optional ( Type . Boolean ( ) ) ,
1012} ) ;
1113
1214const ReplySchema = Type . Object ( {
@@ -33,7 +35,7 @@ export async function signMessage(fastify: FastifyInstance) {
3335 } ,
3436 } ,
3537 handler : async ( req , res ) => {
36- const { message } = req . body ;
38+ const { message, isBytes } = req . body ;
3739 const walletAddress = req . headers [ "x-backend-wallet-address" ] as string ;
3840
3941 const wallet = await getWallet ( {
@@ -42,7 +44,15 @@ export async function signMessage(fastify: FastifyInstance) {
4244 } ) ;
4345
4446 const signer = await wallet . getSigner ( ) ;
45- const signedMessage = await signer . signMessage ( message ) ;
47+
48+ let signedMessage ;
49+ if ( isBytes ) {
50+ signedMessage = await signer . signMessage (
51+ ethers . utils . arrayify ( message ) ,
52+ ) ;
53+ } else {
54+ signedMessage = await signer . signMessage ( message ) ;
55+ }
4656
4757 res . status ( 200 ) . send ( {
4858 result : signedMessage ,
0 commit comments