mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-17 00:31:34 +03:00
21 lines
690 B
TypeScript
21 lines
690 B
TypeScript
import { ethers } from 'ethers';
|
|
import { arrayify, joinSignature, splitSignature } from 'ethers/lib/utils';
|
|
import { CancelOrderRequest } from '../types';
|
|
|
|
const signCancelOrderPersonal = async (
|
|
cancelOrderRequest: CancelOrderRequest,
|
|
signer: ethers.Signer,
|
|
) => {
|
|
const types = ['string', 'string', 'address'];
|
|
const message = ethers.utils.solidityKeccak256(
|
|
types,
|
|
['cancelOrder', cancelOrderRequest.id, cancelOrderRequest.senderAddress],
|
|
);
|
|
const signature = await signer.signMessage(arrayify(message));
|
|
|
|
// NOTE: metamask broke sig.v value and we fix it in next line
|
|
return joinSignature(splitSignature(signature));
|
|
};
|
|
|
|
export default signCancelOrderPersonal;
|