From e5d4f5a2b179a7b3cc2d61beb65284b6d810342d Mon Sep 17 00:00:00 2001 From: Mikhail Gladchenko Date: Wed, 1 Nov 2023 15:08:34 +0000 Subject: [PATCH] feature: updated version to 0.20.14-rc0 --- package.json | 2 +- src/crypt/index.ts | 2 -- src/crypt/signCancelOrder.ts | 16 +++++--------- src/crypt/signCancelOrderPersonal.ts | 19 ----------------- src/crypt/signOrder.ts | 15 +++++--------- src/crypt/signOrderPersonal.ts | 31 ---------------------------- src/types.ts | 2 -- 7 files changed, 11 insertions(+), 76 deletions(-) delete mode 100644 src/crypt/signCancelOrderPersonal.ts delete mode 100644 src/crypt/signOrderPersonal.ts diff --git a/package.json b/package.json index b256294..fa10312 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.13", + "version": "0.20.14-rc0", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/crypt/index.ts b/src/crypt/index.ts index 8dbb278..d09530a 100644 --- a/src/crypt/index.ts +++ b/src/crypt/index.ts @@ -1,4 +1,2 @@ export { default as signCancelOrder } from './signCancelOrder.js'; -export { default as signCancelOrderPersonal } from './signCancelOrderPersonal.js'; export { default as signOrder } from './signOrder.js'; -export { default as signOrderPersonal } from './signOrderPersonal.js'; diff --git a/src/crypt/signCancelOrder.ts b/src/crypt/signCancelOrder.ts index ff49d22..f9bd329 100644 --- a/src/crypt/signCancelOrder.ts +++ b/src/crypt/signCancelOrder.ts @@ -3,33 +3,27 @@ import { ethers } from 'ethers'; import CANCEL_ORDER_TYPES from '../constants/cancelOrderTypes.js'; import type { CancelOrderRequest, SignedCancelOrderRequest, SupportedChainId } from '../types.js'; import getDomainData from './getDomainData.js'; -import signCancelOrderPersonal from './signCancelOrderPersonal.js'; type SignerWithTypedDataSign = ethers.Signer & TypedDataSigner; const signCancelOrder = async ( senderAddress: string, id: string, - usePersonalSign: boolean, signer: ethers.Signer, chainId: SupportedChainId, ) => { const cancelOrderRequest: CancelOrderRequest = { id, senderAddress, - isPersonalSign: usePersonalSign, }; // eslint-disable-next-line @typescript-eslint/consistent-type-assertions const typedDataSigner = signer as SignerWithTypedDataSign; - const signature = usePersonalSign - ? await signCancelOrderPersonal(cancelOrderRequest, signer) - // https://docs.ethers.io/v5/api/signer/#Signer-signTypedData - : await typedDataSigner.signTypedData( - getDomainData(chainId), - CANCEL_ORDER_TYPES, - cancelOrderRequest, - ); + const signature = await typedDataSigner.signTypedData( + getDomainData(chainId), + CANCEL_ORDER_TYPES, + cancelOrderRequest, + ); // 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" diff --git a/src/crypt/signCancelOrderPersonal.ts b/src/crypt/signCancelOrderPersonal.ts deleted file mode 100644 index 2837c3b..0000000 --- a/src/crypt/signCancelOrderPersonal.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { ethers } from 'ethers'; -import type { CancelOrderRequest } from '../types.js'; - -const signCancelOrderPersonal = async ( - cancelOrderRequest: CancelOrderRequest, - signer: ethers.Signer, -) => { - const types = ['string', 'string', 'address']; - const message = ethers.solidityPackedKeccak256( - types, - ['cancelOrder', cancelOrderRequest.id, cancelOrderRequest.senderAddress], - ); - const signature = await signer.signMessage(ethers.getBytes(message)); - - // NOTE: metamask broke sig.v value and we fix it in next line - return ethers.Signature.from(signature).serialized; -}; - -export default signCancelOrderPersonal; diff --git a/src/crypt/signOrder.ts b/src/crypt/signOrder.ts index 90e59df..fca41a7 100644 --- a/src/crypt/signOrder.ts +++ b/src/crypt/signOrder.ts @@ -7,7 +7,6 @@ import type { Order, SignedOrder, SupportedChainId } from '../types.js'; import normalizeNumber from '../utils/normalizeNumber.js'; import getDomainData from './getDomainData.js'; import hashOrder from './hashOrder.js'; -import signOrderPersonal from './signOrderPersonal.js'; const DEFAULT_EXPIRATION = 29 * 24 * 60 * 60 * 1000; // 29 days @@ -23,7 +22,6 @@ export const signOrder = async ( senderAddress: string, matcherAddress: string, serviceFeeAssetAddr: string, - usePersonalSign: boolean, signer: ethers.Signer, chainId: SupportedChainId, ) => { @@ -54,19 +52,16 @@ export const signOrder = async ( nonce, expiration, buySide: side === 'BUY' ? 1 : 0, - isPersonalSign: usePersonalSign, }; // eslint-disable-next-line @typescript-eslint/consistent-type-assertions const typedDataSigner = signer as SignerWithTypedDataSign; - const signature = usePersonalSign - ? await signOrderPersonal(order, signer) - : await typedDataSigner.signTypedData( - getDomainData(chainId), - ORDER_TYPES, - order, - ); + const signature = await typedDataSigner.signTypedData( + getDomainData(chainId), + ORDER_TYPES, + order, + ); // 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" diff --git a/src/crypt/signOrderPersonal.ts b/src/crypt/signOrderPersonal.ts deleted file mode 100644 index 4573e96..0000000 --- a/src/crypt/signOrderPersonal.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ethers } from 'ethers'; -import type { Order } from '../types.js'; - -const signOrderPersonal = async (order: Order, signer: ethers.Signer) => { - const message = ethers.solidityPackedKeccak256( - [ - '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(ethers.getBytes(message)); - - // NOTE: metamask broke sig.v value and we fix it in next line - return ethers.Signature.from(signature).serialized; -}; - -export default signOrderPersonal; diff --git a/src/types.ts b/src/types.ts index be08dd2..a528108 100644 --- a/src/types.ts +++ b/src/types.ts @@ -48,7 +48,6 @@ export type Order = { nonce: number // uint64 expiration: number // uint64 buySide: 0 | 1 // uint8, 1=buy, 0=sell - isPersonalSign: boolean // bool } export type SignedOrder = { @@ -60,7 +59,6 @@ export type SignedOrder = { export type CancelOrderRequest = { id: number | string senderAddress: string - isPersonalSign: boolean } export type SignedCancelOrderRequest = {