feat: update ethers@6

fix: bigint errors

fix: TS errors

fix: gasLimit fetch

fix: review comments

fix: contracts errors

chore: bump rc version

fix: revert wrong fix

fix: ts config

fix: ts config

fix: ts config

feat: update signer
This commit is contained in:
Oleg Nechiporenko
2023-09-07 00:12:07 +03:00
parent 27c426e815
commit c2a4084158
38 changed files with 409 additions and 608 deletions

View File

@@ -1,7 +1,6 @@
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
import { BigNumber } from 'bignumber.js';
import type { ethers } from 'ethers';
import { joinSignature, splitSignature } from 'ethers/lib/utils.js';
import { ethers } from 'ethers';
import { INTERNAL_PROTOCOL_PRECISION } from '../constants/index.js';
import ORDER_TYPES from '../constants/orderTypes.js';
import type { Order, SignedOrder, SupportedChainId } from '../types.js';
@@ -37,21 +36,21 @@ export const signOrder = async (
baseAsset: baseAssetAddr,
quoteAsset: quoteAssetAddr,
matcherFeeAsset: serviceFeeAssetAddr,
amount: normalizeNumber(
amount: Number(normalizeNumber(
amount,
INTERNAL_PROTOCOL_PRECISION,
BigNumber.ROUND_FLOOR,
).toNumber(),
price: normalizeNumber(
)),
price: Number(normalizeNumber(
price,
INTERNAL_PROTOCOL_PRECISION,
BigNumber.ROUND_FLOOR,
).toNumber(),
matcherFee: normalizeNumber(
)),
matcherFee: Number(normalizeNumber(
matcherFee,
INTERNAL_PROTOCOL_PRECISION,
BigNumber.ROUND_CEIL, // ROUND_CEIL because we don't want get "not enough fee" error
).toNumber(),
)),
nonce,
expiration,
buySide: side === 'BUY' ? 1 : 0,
@@ -63,7 +62,7 @@ export const signOrder = async (
const signature = usePersonalSign
? await signOrderPersonal(order, signer)
: await typedDataSigner._signTypedData(
: await typedDataSigner.signTypedData(
getDomainData(chainId),
ORDER_TYPES,
order,
@@ -71,7 +70,7 @@ export const signOrder = async (
// https://github.com/poap-xyz/poap-fun/pull/62#issue-928290265
// "Signature's v was always send as 27 or 28, but from Ledger was 0 or 1"
const fixedSignature = joinSignature(splitSignature(signature));
const fixedSignature = ethers.Signature.from(signature).serialized;
// if (!fixedSignature) throw new Error("Can't sign order");