diff --git a/cypress-custom/integration/fee.test.ts b/cypress-custom/integration/fee.test.ts index df336221c8..7b6048d6d7 100644 --- a/cypress-custom/integration/fee.test.ts +++ b/cypress-custom/integration/fee.test.ts @@ -1,5 +1,5 @@ import { WETH9 as WETH } from '@uniswap/sdk-core' -import { GetQuoteResponse } from '@gnosis.pm/gp-v2-contracts' +import { GetQuoteResponse } from '@cowprotocol/contracts' import { parseUnits } from 'ethers/lib/utils' const DAI = '0xc7AD46e0b8a400Bb3C915120d284AafbA8fc4735' diff --git a/package.json b/package.json index 13cad958ad..686263884b 100644 --- a/package.json +++ b/package.json @@ -190,6 +190,7 @@ "license": "GPL-3.0-or-later", "dependencies": { "@babel/runtime": "^7.17.0", + "@cowprotocol/contracts": "^1.1.3-RC.0", "@davatar/react": "1.8.1", "@ethersproject/abi": "^5.4.1", "@ethersproject/abstract-provider": "^5.4.1", @@ -210,7 +211,6 @@ "@fontsource/inter": "^4.5.1", "@gnosis.pm/cow-runner-game": "^0.2.9", "@gnosis.pm/dex-js": "^0.14.0", - "@gnosis.pm/gp-v2-contracts": "^1.1.2", "@gnosis.pm/safe-apps-web3-react": "^0.6.0", "@gnosis.pm/safe-service-client": "^0.1.1", "@lingui/cli": "^3.9.0", diff --git a/src/custom/api/gnosisProtocol/api.ts b/src/custom/api/gnosisProtocol/api.ts index cefb2946a5..c7bc149f4e 100644 --- a/src/custom/api/gnosisProtocol/api.ts +++ b/src/custom/api/gnosisProtocol/api.ts @@ -1,5 +1,5 @@ import { SupportedChainId as ChainId, SupportedChainId } from 'constants/chains' -import { OrderKind, QuoteQuery } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind, QuoteQuery } from '@cowprotocol/contracts' import { stringify } from 'qs' import { getSigningSchemeApiValue, diff --git a/src/custom/api/matcha-0x/index.ts b/src/custom/api/matcha-0x/index.ts index c7acea9e54..6fdc52b2d6 100644 --- a/src/custom/api/matcha-0x/index.ts +++ b/src/custom/api/matcha-0x/index.ts @@ -1,4 +1,4 @@ -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { NetworkID } from 'paraswap' import { SupportedChainId as ChainId } from 'constants/chains' diff --git a/src/custom/api/paraswap/index.ts b/src/custom/api/paraswap/index.ts index fa09c7ba9d..78a370b3f3 100644 --- a/src/custom/api/paraswap/index.ts +++ b/src/custom/api/paraswap/index.ts @@ -1,4 +1,4 @@ -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { ParaSwap, SwapSide, NetworkID } from 'paraswap' import { OptimalRate } from 'paraswap-core' diff --git a/src/custom/components/Version/index.tsx b/src/custom/components/Version/index.tsx index 1c017f0245..54af2fbc55 100644 --- a/src/custom/components/Version/index.tsx +++ b/src/custom/components/Version/index.tsx @@ -2,7 +2,7 @@ import styled from 'styled-components/macro' import { ExternalLink, ThemedText } from 'theme' import { version as WEB_VERSION } from '@src/../package.json' -import { version as CONTRACTS_VERSION } from '@gnosis.pm/gp-v2-contracts/package.json' +import { version as CONTRACTS_VERSION } from '@cowprotocol/contracts/package.json' import { SupportedChainId as ChainId } from 'constants/chains' import { getEtherscanLink } from 'utils' import { CODE_LINK, GP_VAULT_RELAYER, GP_SETTLEMENT_CONTRACT_ADDRESS } from 'constants/index' diff --git a/src/custom/constants/index.ts b/src/custom/constants/index.ts index 29c0710a65..16ddf74b8e 100644 --- a/src/custom/constants/index.ts +++ b/src/custom/constants/index.ts @@ -1,6 +1,6 @@ import { Token, Fraction, Percent } from '@uniswap/sdk-core' -import { GPv2Settlement, GPv2VaultRelayer } from '@gnosis.pm/gp-v2-contracts/networks.json' +import { GPv2Settlement, GPv2VaultRelayer } from '@cowprotocol/contracts/networks.json' import { WalletInfo, SUPPORTED_WALLETS as SUPPORTED_WALLETS_UNISWAP } from 'constants/wallet' import { SupportedChainId as ChainId } from 'constants/chains' diff --git a/src/custom/hooks/usePriceImpact/useQuoteAndSwap.ts b/src/custom/hooks/usePriceImpact/useQuoteAndSwap.ts index c9b3d977e0..cfd6328b4c 100644 --- a/src/custom/hooks/usePriceImpact/useQuoteAndSwap.ts +++ b/src/custom/hooks/usePriceImpact/useQuoteAndSwap.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { Currency, CurrencyAmount } from '@uniswap/sdk-core' import { useTradeExactInWithFee } from 'state/swap/extension' diff --git a/src/custom/hooks/useSwapCallback.ts b/src/custom/hooks/useSwapCallback.ts index 343c5e42c7..e36058fb49 100644 --- a/src/custom/hooks/useSwapCallback.ts +++ b/src/custom/hooks/useSwapCallback.ts @@ -13,7 +13,7 @@ import useENS from '@src/hooks/useENS' // import useTransactionDeadline from './useTransactionDeadline' // MOD -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { INITIAL_ALLOWED_SLIPPAGE_PERCENT, NATIVE_CURRENCY_BUY_TOKEN } from 'constants/index' import { AddOrderCallback, AddUnserialisedPendingOrderParams, useAddPendingOrder } from 'state/orders/hooks' import { useWrapEther, Wrap } from 'hooks/useWrapEther' diff --git a/src/custom/state/orders/actions.ts b/src/custom/state/orders/actions.ts index cda54d6b72..0502a467b7 100644 --- a/src/custom/state/orders/actions.ts +++ b/src/custom/state/orders/actions.ts @@ -6,7 +6,7 @@ import { SupportedChainId as ChainId } from 'constants/chains' import { SerializedToken } from '@src/state/user/actions' import { SafeMultisigTransactionResponse } from '@gnosis.pm/safe-service-client' import { BigNumberish } from '@ethersproject/bignumber' -export { OrderKind } from '@gnosis.pm/gp-v2-contracts' +export { OrderKind } from '@cowprotocol/contracts' export enum OrderStatus { PENDING = 'pending', diff --git a/src/custom/state/orders/updaters/UnfillableOrdersUpdater.ts b/src/custom/state/orders/updaters/UnfillableOrdersUpdater.ts index ed56163745..4b474ed292 100644 --- a/src/custom/state/orders/updaters/UnfillableOrdersUpdater.ts +++ b/src/custom/state/orders/updaters/UnfillableOrdersUpdater.ts @@ -1,5 +1,5 @@ import { useCallback, useEffect, useRef } from 'react' -import { timestamp } from '@gnosis.pm/gp-v2-contracts' +import { timestamp } from '@cowprotocol/contracts' import { useActiveWeb3React } from 'hooks/web3' diff --git a/src/custom/state/orders/utils.ts b/src/custom/state/orders/utils.ts index 1839c9fd3a..c37322d81b 100644 --- a/src/custom/state/orders/utils.ts +++ b/src/custom/state/orders/utils.ts @@ -1,4 +1,4 @@ -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { Price } from '@uniswap/sdk-core' import { ONE_HUNDRED_PERCENT } from 'constants/misc' diff --git a/src/custom/state/price/reducer.ts b/src/custom/state/price/reducer.ts index 5f6ac9bafb..e08b60a9b2 100644 --- a/src/custom/state/price/reducer.ts +++ b/src/custom/state/price/reducer.ts @@ -1,6 +1,6 @@ import { createReducer, PayloadAction, current } from '@reduxjs/toolkit' import { SupportedChainId as ChainId } from 'constants/chains' -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { updateQuote, setQuoteError, getNewQuote, refreshQuote, QuoteError } from './actions' import { Writable } from 'custom/types' import { PrefillStateRequired } from '../orders/reducer' diff --git a/src/custom/state/price/updater.ts b/src/custom/state/price/updater.ts index 657533a75f..955ff39af6 100644 --- a/src/custom/state/price/updater.ts +++ b/src/custom/state/price/updater.ts @@ -4,7 +4,7 @@ import { DEFAULT_DECIMALS } from 'custom/constants' import { UnsupportedToken } from 'api/gnosisProtocol' import { FeeQuoteParams as FeeQuoteParamsFull } from 'utils/price' -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { useSwapState } from 'state/swap/hooks' import tryParseCurrencyAmount from 'lib/utils/tryParseCurrencyAmount' diff --git a/src/custom/state/swap/extension.ts b/src/custom/state/swap/extension.ts index 082644396b..661f7f8c38 100644 --- a/src/custom/state/swap/extension.ts +++ b/src/custom/state/swap/extension.ts @@ -2,7 +2,7 @@ import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core' import JSBI from 'jsbi' import { QuoteInformationObject } from 'state/price/reducer' import TradeGp, { _constructTradePrice } from './TradeGp' -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' interface TradeParams { parsedAmount?: CurrencyAmount diff --git a/src/custom/state/swap/trade.test.ts b/src/custom/state/swap/trade.test.ts index 3268411afb..f9e33c48eb 100644 --- a/src/custom/state/swap/trade.test.ts +++ b/src/custom/state/swap/trade.test.ts @@ -1,7 +1,7 @@ import { parseUnits } from '@ethersproject/units' import { DEFAULT_PRECISION, LONG_PRECISION } from 'constants/index' import { CurrencyAmount, Fraction, Price, Currency, Percent, Token, TradeType } from '@uniswap/sdk-core' -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' import { stringToCurrency } from './extension' import { SupportedChainId as ChainId } from 'constants/chains' import { WRAPPED_NATIVE_CURRENCY as WETH } from 'constants/tokens' diff --git a/src/custom/utils/misc.ts b/src/custom/utils/misc.ts index 27b354e38c..a9ba71d054 100644 --- a/src/custom/utils/misc.ts +++ b/src/custom/utils/misc.ts @@ -1,6 +1,6 @@ import { SupportedChainId as ChainId } from 'constants/chains' import { Market } from 'types/index' -import { OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { OrderKind } from '@cowprotocol/contracts' export const isTruthy = (value: T | null | undefined | false): value is T => !!value diff --git a/src/custom/utils/price.ts b/src/custom/utils/price.ts index 8998c0d4fb..d7a8c3b220 100644 --- a/src/custom/utils/price.ts +++ b/src/custom/utils/price.ts @@ -16,7 +16,7 @@ import { } from 'api/matcha-0x' import { OptimalRate } from 'paraswap-core' -import { GetQuoteResponse, OrderKind } from '@gnosis.pm/gp-v2-contracts' +import { GetQuoteResponse, OrderKind } from '@cowprotocol/contracts' import { ChainId } from 'state/lists/actions' import { toErc20Address } from 'utils/tokens' import { GpPriceStrategy } from 'hooks/useGetGpPriceStrategy' @@ -45,7 +45,7 @@ export interface PriceInformation { amount: string | null } -// GetQuoteResponse from @gnosis.pm/gp-v2-contracts types Timestamp and BigNumberish +// GetQuoteResponse from @cowprotocol/contracts types Timestamp and BigNumberish // do not play well with our existing methods, using string instead export type SimpleGetQuoteResponse = Pick & { // We need to map BigNumberIsh and Timestamp to what we use: string diff --git a/src/custom/utils/signatures.ts b/src/custom/utils/signatures.ts index 6e27180e46..c1f648de0a 100644 --- a/src/custom/utils/signatures.ts +++ b/src/custom/utils/signatures.ts @@ -6,10 +6,10 @@ import { Order, OrderCancellation as OrderCancellationGp, Signature, - TypedDataV3Signer, + TypedDataVersionedSigner, IntChainIdTypedDataV4Signer, SigningScheme, -} from '@gnosis.pm/gp-v2-contracts' +} from '@cowprotocol/contracts' import { SupportedChainId as ChainId } from 'constants/chains' import { GP_SETTLEMENT_CONTRACT_ADDRESS } from 'constants/index' @@ -137,7 +137,7 @@ async function _signPayload( payload: any, signFn: typeof _signOrder | typeof _signOrderCancellation, signer: Signer, - signingMethod: 'v4' | 'int_v4' | 'v3' | 'eth_sign' = 'v4' + signingMethod: 'default' | 'v4' | 'int_v4' | 'v3' | 'eth_sign' = 'v4' ): Promise { const signingScheme = signingMethod === 'eth_sign' ? SigningScheme.ETHSIGN : SigningScheme.EIP712 let signature: Signature | null = null @@ -145,8 +145,11 @@ async function _signPayload( let _signer try { switch (signingMethod) { + case 'default': + _signer = new TypedDataVersionedSigner(signer) + break case 'v3': - _signer = new TypedDataV3Signer(signer) + _signer = new TypedDataVersionedSigner(signer, 'v3') break case 'int_v4': _signer = new IntChainIdTypedDataV4Signer(signer) @@ -173,6 +176,8 @@ async function _signPayload( // with other methods... switch (signingMethod) { case 'v4': + return _signPayload(payload, signFn, signer, 'default') + case 'default': return _signPayload(payload, signFn, signer, 'v3') case 'v3': return _signPayload(payload, signFn, signer, 'eth_sign') diff --git a/src/custom/utils/trade.ts b/src/custom/utils/trade.ts index fea92f03c1..017038d6f3 100644 --- a/src/custom/utils/trade.ts +++ b/src/custom/utils/trade.ts @@ -9,7 +9,7 @@ import { Signer } from '@ethersproject/abstract-signer' import { RADIX_DECIMAL, AMOUNT_PRECISION } from 'constants/index' import { SupportedChainId as ChainId } from 'constants/chains' import { formatSmart } from 'utils/format' -import { SigningScheme } from '@gnosis.pm/gp-v2-contracts' +import { SigningScheme } from '@cowprotocol/contracts' import { getTrades, getProfileData } from 'api/gnosisProtocol/api' export interface PostOrderParams { diff --git a/src/custom/writeVersion.js b/src/custom/writeVersion.js index 85a981ac26..a1af5da8f9 100644 --- a/src/custom/writeVersion.js +++ b/src/custom/writeVersion.js @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-var-requires */ const fs = require('fs') const { version: WEB_VERSION } = require('../../package.json') -const { version: CONTRACTS_VERSION } = require('@gnosis.pm/gp-v2-contracts/package.json') +const { version: CONTRACTS_VERSION } = require('@cowprotocol/contracts/package.json') const OUTPUT_FILE = 'public/version.json' diff --git a/yarn.lock b/yarn.lock index 97ef7c8d65..0c1d882a4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1160,6 +1160,11 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@cowprotocol/contracts@^1.1.3-RC.0": + version "1.1.3-RC.0" + resolved "https://registry.yarnpkg.com/@cowprotocol/contracts/-/contracts-1.1.3-RC.0.tgz#23c400a7cbf50c1c2e7dca317a0b2940975b6867" + integrity sha512-WwPvBKbBvRIj/W3I1/8yJPh0DLMx8EoDw/MTpF07rDq2W0QQ1r9GXq+GWIclt5Rcw7ZGwZMRlnM3XOYEWA+qpg== + "@craco/craco@^5.7.0": version "5.9.0" resolved "https://registry.yarnpkg.com/@craco/craco/-/craco-5.9.0.tgz#dcd34330b558596a4841374743071b7fa041dce9" @@ -2142,11 +2147,6 @@ "@gnosis.pm/dex-contracts" "^0.5.0" bignumber.js "^9.0.2" -"@gnosis.pm/gp-v2-contracts@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@gnosis.pm/gp-v2-contracts/-/gp-v2-contracts-1.1.2.tgz#0453bb097377dc63cf46ee195f7e521d429f7e22" - integrity sha512-BvZMNS+fwITb+qs+trs2fyvYksa6MPjjLze9AOXPnvcKVYFEGwG6cfsecBswEMo+xevLIQNDyF7HZRhN7ply8w== - "@gnosis.pm/safe-apps-provider@0.9.3": version "0.9.3" resolved "https://registry.yarnpkg.com/@gnosis.pm/safe-apps-provider/-/safe-apps-provider-0.9.3.tgz#d8913b0f8abc15fdca229571eefc5f9385c82ea7"