mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-18 03:45:02 +03:00
File structure improvements
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { Order } from '../types';
|
||||
|
||||
const hashOrder = (order: Order) => ethers.utils.solidityKeccak256(
|
||||
[
|
||||
'uint8',
|
||||
'address',
|
||||
'address',
|
||||
'address',
|
||||
'address',
|
||||
'address',
|
||||
'uint64',
|
||||
'uint64',
|
||||
'uint64',
|
||||
'uint64',
|
||||
'uint64',
|
||||
'uint8',
|
||||
],
|
||||
[
|
||||
'0x03',
|
||||
order.senderAddress,
|
||||
order.matcherAddress,
|
||||
order.baseAsset,
|
||||
order.quoteAsset,
|
||||
order.matcherFeeAsset,
|
||||
order.amount,
|
||||
order.price,
|
||||
order.matcherFee,
|
||||
order.nonce,
|
||||
order.expiration,
|
||||
order.buySide ? '0x01' : '0x00',
|
||||
],
|
||||
);
|
||||
|
||||
export default hashOrder;
|
||||
@@ -2,9 +2,7 @@ export { default as calculateFeeInFeeAsset } from './calculateFeeInFeeAsset';
|
||||
export { default as calculateNetworkFee } from './calculateNetworkFee';
|
||||
export { default as calculateNetworkFeeInFeeAsset } from './calculateNetworkFeeInFeeAsset';
|
||||
export { default as calculateOrionFeeInFeeAsset } from './calculateOrionFeeInFeeAsset';
|
||||
export { default as hashOrder } from './hashOrder';
|
||||
export { default as checkIsToken } from './checkIsToken';
|
||||
export { default as signOrderPersonal } from './signOrderPersonal';
|
||||
export { default as generateSecret } from './generateSecret';
|
||||
export { default as isValidChainId } from './isValidChainId';
|
||||
export { default as denormalizeNumber } from './denormalizeNumber';
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { Order } from '../types';
|
||||
|
||||
const { arrayify, joinSignature, splitSignature } = ethers.utils;
|
||||
|
||||
const signOrderPersonal = async (order: Order, signer: ethers.Signer) => {
|
||||
const message = ethers.utils.solidityKeccak256(
|
||||
[
|
||||
'string', 'address', 'address', 'address', 'address',
|
||||
'address', 'uint64', 'uint64', 'uint64', 'uint64', 'uint64', 'uint8',
|
||||
],
|
||||
[
|
||||
'order',
|
||||
order.senderAddress,
|
||||
order.matcherAddress,
|
||||
order.baseAsset,
|
||||
order.quoteAsset,
|
||||
order.matcherFeeAsset,
|
||||
order.amount,
|
||||
order.price,
|
||||
order.matcherFee,
|
||||
order.nonce,
|
||||
order.expiration,
|
||||
order.buySide,
|
||||
],
|
||||
);
|
||||
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 signOrderPersonal;
|
||||
Reference in New Issue
Block a user