import * as constants from './constants' export const signUserOp = async (projectId: string, userOp: any): Promise => { const resp = await fetch(`${constants.PAYMASTER_URL}/sign`, { method: 'POST', body: JSON.stringify({ projectId: projectId, userOp: userOp, }), headers: { 'Content-Type': 'application/json' } }) const { signature } = await resp.json() return signature } export const getChainId = async (projectId: string): Promise => { const resp = await fetch(`${constants.BACKEND_URL}/v1/projects/get-chain-id`, { method: 'POST', body: JSON.stringify({ projectId: projectId, }), headers: { 'Content-Type': 'application/json' } }) const { chainId } = await resp.json() return chainId } export const getPrivateKeyByToken = async (projectId: string, identity: string, token: string): Promise => { const resp = await fetch(`${constants.BACKEND_URL}/v1/keys/get-by-token`, { method: 'POST', body: JSON.stringify({ projectId, identity, token, }), headers: { 'Content-Type': 'application/json' } }) const { privateKey } = await resp.json() return privateKey }