mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-17 00:31:34 +03:00
Strictest / tests / minor improvements
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
import { type SupportedChainId } from '../types';
|
||||
import type { SupportedChainId } from '../types';
|
||||
import eip712DomainData from '../config/eip712DomainData.json';
|
||||
import eip712DomainSchema from '../config/schemas/eip712DomainSchema';
|
||||
|
||||
const EIP712Domain = eip712DomainSchema.parse(eip712DomainData);
|
||||
|
||||
function removeUndefined<T>(obj: Record<string, T | undefined>) {
|
||||
const newObj: Partial<Record<string, T>> = {};
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value !== undefined) {
|
||||
newObj[key] = value;
|
||||
}
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator}
|
||||
*/
|
||||
const getDomainData = (chainId: SupportedChainId) => ({
|
||||
...EIP712Domain,
|
||||
...removeUndefined(EIP712Domain),
|
||||
chainId,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { type CFDOrder } from '../types';
|
||||
import type { CFDOrder } from '../types';
|
||||
|
||||
const hashCFDOrder = (order: CFDOrder) => ethers.utils.solidityKeccak256(
|
||||
[
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { type Order } from '../types';
|
||||
import type { Order } from '../types';
|
||||
|
||||
const hashOrder = (order: Order) => ethers.utils.solidityKeccak256(
|
||||
[
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { type TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import { type ethers } from 'ethers';
|
||||
import type { ethers } from 'ethers';
|
||||
import { joinSignature, splitSignature } from 'ethers/lib/utils';
|
||||
import { INTERNAL_ORION_PRECISION } from '../constants';
|
||||
import { type CFDOrder, type SignedCFDOrder, type SupportedChainId } from '../types';
|
||||
import type { CFDOrder, SignedCFDOrder, SupportedChainId } from '../types';
|
||||
import normalizeNumber from '../utils/normalizeNumber';
|
||||
import getDomainData from './getDomainData';
|
||||
import signCFDOrderPersonal from './signCFDOrderPersonal';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { type CFDOrder } from '../types';
|
||||
import type { CFDOrder } from '../types';
|
||||
|
||||
const { arrayify, joinSignature, splitSignature } = ethers.utils;
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { type TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
import { type ethers } from 'ethers';
|
||||
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
import type { ethers } from 'ethers';
|
||||
import { joinSignature, splitSignature } from 'ethers/lib/utils';
|
||||
import CANCEL_ORDER_TYPES from '../constants/cancelOrderTypes';
|
||||
import { type CancelOrderRequest, type SignedCancelOrderRequest, type SupportedChainId } from '../types';
|
||||
import type { CancelOrderRequest, SignedCancelOrderRequest, SupportedChainId } from '../types';
|
||||
import getDomainData from './getDomainData';
|
||||
import signCancelOrderPersonal from './signCancelOrderPersonal';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { arrayify, joinSignature, splitSignature } from 'ethers/lib/utils';
|
||||
import { type CancelOrderRequest } from '../types';
|
||||
import type { CancelOrderRequest } from '../types';
|
||||
|
||||
const signCancelOrderPersonal = async (
|
||||
cancelOrderRequest: CancelOrderRequest,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { type TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import { type ethers } from 'ethers';
|
||||
import type { ethers } from 'ethers';
|
||||
import { joinSignature, splitSignature } from 'ethers/lib/utils';
|
||||
import { INTERNAL_ORION_PRECISION } from '../constants';
|
||||
import ORDER_TYPES from '../constants/orderTypes';
|
||||
import { type Order, type SignedOrder, type SupportedChainId } from '../types';
|
||||
import type { Order, SignedOrder, SupportedChainId } from '../types';
|
||||
import normalizeNumber from '../utils/normalizeNumber';
|
||||
import getDomainData from './getDomainData';
|
||||
import hashOrder from './hashOrder';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ethers } from 'ethers';
|
||||
import { type Order } from '../types';
|
||||
import type { Order } from '../types';
|
||||
|
||||
const { arrayify, joinSignature, splitSignature } = ethers.utils;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user