@rep3/rep3-sdk
Version:
`rep3-sdk` is the ts package for projects to integrate rep3-protocol and services in their projects. This documentation will provide various ways and code snippets for the same. To know more about the protocol head over to our [docs](https://docs.rep3.gg/
40 lines (36 loc) • 879 B
text/typescript
import axios from 'axios';
import { relayerRequestData, RelayRequestResponse } from '../types';
export enum RelayMethodFunctionCall {
REGISTER,
ADD_APPROVER,
REMOVE_APPROVER,
CLAIM,
BURN,
APPROVE,
}
export const relayerServerCall = async (
relayerUrl: string,
relayerToken: string,
functionCall: RelayMethodFunctionCall,
request: relayerRequestData,
signature: string,
chainId: number
): Promise<RelayRequestResponse> => {
const data = {
function: functionCall,
request_data: request,
signature,
chain_id: chainId,
callback_api: 'https://staging.api.drepute.xyz/eth/callback',
};
try {
const res = await axios.post(`${relayerUrl}/eth/relay`, data, {
headers: {
'X-Authentication': relayerToken,
},
});
return { transactionHash: res.data.data.hash };
} catch (error) {
throw error;
}
};