From d36d616f46b3ad9591aa2a13e8e89f2bfc54bd4b Mon Sep 17 00:00:00 2001 From: TheJuze Date: Thu, 6 Jun 2024 11:05:43 +0300 Subject: [PATCH] remove ledger signature --- package-lock.json | 4 ++-- package.json | 2 +- src/crypt/signCancelOrder.ts | 10 ++-------- src/crypt/signCrossChainOrder.ts | 10 +++------- src/crypt/signLockOrder.ts | 8 +------- src/crypt/signOrder.ts | 10 ++-------- 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index e6a0262..ab58c9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@orionprotocol/sdk", - "version": "0.22.0-rc22", + "version": "0.22.0-rc23", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@orionprotocol/sdk", - "version": "0.22.0-rc22", + "version": "0.22.0-rc23", "hasInstallScript": true, "license": "ISC", "dependencies": { diff --git a/package.json b/package.json index 36066f4..ca46ce3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.22.0-rc22", + "version": "0.22.0-rc23", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/crypt/signCancelOrder.ts b/src/crypt/signCancelOrder.ts index d792401..51fda90 100644 --- a/src/crypt/signCancelOrder.ts +++ b/src/crypt/signCancelOrder.ts @@ -1,4 +1,4 @@ -import { ethers } from 'ethers'; +import type { ethers } from 'ethers'; import CANCEL_ORDER_TYPES from '../constants/cancelOrderTypes.js'; import type { CancelOrderRequest, SignedCancelOrderRequest, SupportedChainId } from '../types.js'; import getDomainData from './getDomainData.js'; @@ -20,15 +20,9 @@ const signCancelOrder = async ( 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" - const fixedSignature = ethers.Signature.from(signature).serialized; - - // if (!fixedSignature) throw new Error("Can't sign order cancel"); - const signedCancelOrderReqeust: SignedCancelOrderRequest = { ...cancelOrderRequest, - signature: fixedSignature, + signature, }; return signedCancelOrderReqeust; }; diff --git a/src/crypt/signCrossChainOrder.ts b/src/crypt/signCrossChainOrder.ts index 8d65d4c..57571af 100644 --- a/src/crypt/signCrossChainOrder.ts +++ b/src/crypt/signCrossChainOrder.ts @@ -1,5 +1,6 @@ import { BigNumber } from 'bignumber.js'; -import { ethers, keccak256 } from 'ethers'; +import type { ethers } from 'ethers'; +import { keccak256 } from 'ethers'; import { INTERNAL_PROTOCOL_PRECISION } from '../constants'; import { CROSS_CHAIN_ORDER_TYPES } from '../constants/orderTypes/orderTypes'; import type { Order, SignedCrossChainOrder, SupportedChainId } from '../types.js'; @@ -87,14 +88,9 @@ export const signCrossChainOrder = async ({ crossChainOrder ); - // 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 = ethers.Signature.from(signature).serialized; - - // if (!fixedSignature) throw new Error("Can't sign order"); const signedOrderWithoutId: Omit = { ...order, - signature: fixedSignature, + signature, secret, secretHash, targetChainId: Number(targetChainId), diff --git a/src/crypt/signLockOrder.ts b/src/crypt/signLockOrder.ts index 3ffb34d..47ea130 100644 --- a/src/crypt/signLockOrder.ts +++ b/src/crypt/signLockOrder.ts @@ -50,15 +50,9 @@ export const signLockOrder = async ({ 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" - const fixedSignature = ethers.Signature.from(signature).serialized; - - // if (!fixedSignature) throw new Error("Can't sign order"); - const signedOrder: SignedLockOrder = { ...order, - signature: fixedSignature, + signature, secret, secretHash }; diff --git a/src/crypt/signOrder.ts b/src/crypt/signOrder.ts index e772620..4623991 100644 --- a/src/crypt/signOrder.ts +++ b/src/crypt/signOrder.ts @@ -1,5 +1,5 @@ import { BigNumber } from 'bignumber.js'; -import { ethers } from 'ethers'; +import type { ethers } from 'ethers'; import { INTERNAL_PROTOCOL_PRECISION, ORDER_TYPES } from '../constants'; import type { Order, SignedOrder, SupportedChainId } from '../types.js'; import normalizeNumber from '../utils/normalizeNumber.js'; @@ -70,16 +70,10 @@ export const signOrder = async ({ 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" - const fixedSignature = ethers.Signature.from(signature).serialized; - - // if (!fixedSignature) throw new Error("Can't sign order"); - const signedOrder: SignedOrder = { ...order, id: hashOrder(order), - signature: fixedSignature, + signature, }; return signedOrder; };