From f5d482e155b5950f7c7749825079625463d57ab1 Mon Sep 17 00:00:00 2001 From: shoom3301 Date: Tue, 26 Dec 2023 16:16:36 +0600 Subject: [PATCH] feat: sepolia network --- src/common/chains.ts | 1 + src/common/consts.ts | 47 +++++++++---------- src/order-book/api.ts | 2 + .../generated/models/OrderPostError.ts | 11 ++--- src/subgraph/api.ts | 2 + 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/common/chains.ts b/src/common/chains.ts index 80e21698..69b7fd9f 100644 --- a/src/common/chains.ts +++ b/src/common/chains.ts @@ -6,4 +6,5 @@ export enum SupportedChainId { MAINNET = 1, GOERLI = 5, GNOSIS_CHAIN = 100, + SEPOLIA = 11155111, } diff --git a/src/common/consts.ts b/src/common/consts.ts index da014b94..26ab0450 100644 --- a/src/common/consts.ts +++ b/src/common/consts.ts @@ -1,12 +1,13 @@ import { SupportedChainId } from './chains' -import contractNetworks from '@cowprotocol/contracts/networks.json' - -const { GPv2Settlement } = JSON.parse(contractNetworks as unknown as string) as typeof contractNetworks export const BUY_ETH_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE' export const EXTENSIBLE_FALLBACK_HANDLER = '0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5' export const COMPOSABLE_COW = '0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74' +// TODO: use addresses from the contracts repo +const VAULT_RELAYER = '0xC92E8bdf79f0507f65a392b0ab4667716BFE0110' +const SETTLEMENT_CONTRACT = '0x9008D19f58AAbD9eD0D60971565AA8510560ab41' + /** * The list of supported chains. */ @@ -14,37 +15,35 @@ export const ALL_SUPPORTED_CHAIN_IDS: SupportedChainId[] = [ SupportedChainId.MAINNET, SupportedChainId.GOERLI, SupportedChainId.GNOSIS_CHAIN, + SupportedChainId.SEPOLIA, ] +export function mapAddressToSupportedNetworks(address: string): Record { + return ALL_SUPPORTED_CHAIN_IDS.reduce>( + (acc, chainId) => ({ + ...acc, + [chainId]: address, + }), + {} + ) +} + /** * An object containing the addresses of the CoW Protocol settlement contracts for each supported chain. */ -export const COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS = ALL_SUPPORTED_CHAIN_IDS.reduce>( - (acc, chainId) => ({ - ...acc, - [chainId]: GPv2Settlement[chainId].address, - }), - {} -) +export const COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS = mapAddressToSupportedNetworks(SETTLEMENT_CONTRACT) + +/** + * An object containing the addresses of the CoW Protocol Vault realyer contracts for each supported chain. + */ +export const COW_PROTOCOL_VAULT_RELAYER_ADDRESS = mapAddressToSupportedNetworks(VAULT_RELAYER) /** * An object containing the addresses of the `ExtensibleFallbackHandler` contracts for each supported chain. */ -export const EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS = ALL_SUPPORTED_CHAIN_IDS.reduce>( - (acc, chainId) => ({ - ...acc, - [chainId]: EXTENSIBLE_FALLBACK_HANDLER, - }), - {} -) +export const EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS = mapAddressToSupportedNetworks(EXTENSIBLE_FALLBACK_HANDLER) /** * An object containing the addresses of the `ComposableCow` contracts for each supported chain. */ -export const COMPOSABLE_COW_CONTRACT_ADDRESS = ALL_SUPPORTED_CHAIN_IDS.reduce>( - (acc, chainId) => ({ - ...acc, - [chainId]: COMPOSABLE_COW, - }), - {} -) +export const COMPOSABLE_COW_CONTRACT_ADDRESS = mapAddressToSupportedNetworks(COMPOSABLE_COW) diff --git a/src/order-book/api.ts b/src/order-book/api.ts index 942b001a..eb420497 100644 --- a/src/order-book/api.ts +++ b/src/order-book/api.ts @@ -39,6 +39,7 @@ export const ORDER_BOOK_PROD_CONFIG: ApiBaseUrls = { [SupportedChainId.MAINNET]: 'https://api.cow.fi/mainnet', [SupportedChainId.GNOSIS_CHAIN]: 'https://api.cow.fi/xdai', [SupportedChainId.GOERLI]: 'https://api.cow.fi/goerli', + [SupportedChainId.SEPOLIA]: 'https://api.cow.fi/sepolia', } /** @@ -48,6 +49,7 @@ export const ORDER_BOOK_STAGING_CONFIG: ApiBaseUrls = { [SupportedChainId.MAINNET]: 'https://barn.api.cow.fi/mainnet', [SupportedChainId.GNOSIS_CHAIN]: 'https://barn.api.cow.fi/xdai', [SupportedChainId.GOERLI]: 'https://barn.api.cow.fi/goerli', + [SupportedChainId.SEPOLIA]: 'https://barn.api.cow.fi/sepolia', } function cleanObjectFromUndefinedValues(obj: Record): typeof obj { diff --git a/src/order-book/generated/models/OrderPostError.ts b/src/order-book/generated/models/OrderPostError.ts index c1fee9ac..6aa0d310 100644 --- a/src/order-book/generated/models/OrderPostError.ts +++ b/src/order-book/generated/models/OrderPostError.ts @@ -23,20 +23,17 @@ export namespace OrderPostError { SELL_AMOUNT_OVERFLOW = 'SellAmountOverflow', TRANSFER_SIMULATION_FAILED = 'TransferSimulationFailed', ZERO_AMOUNT = 'ZeroAmount', - INCOMPATIBLE_SIGNING_SCHEME = 'IncompatibleSigningScheme', - UNSUPPORTED_BUY_TOKEN_DESTINATION = 'UnsupportedBuyTokenDestination', + INCOMPATIBLE_SIGNING_SCHEME = 'IncompatibleSigningScheme', + TOO_MANY_LIMIT_ORDERS_UNSUPPORTED_BUY_TOKEN_DESTINATION = 'TooManyLimitOrders UnsupportedBuyTokenDestination', UNSUPPORTED_SELL_TOKEN_SOURCE = 'UnsupportedSellTokenSource', UNSUPPORTED_ORDER_TYPE = 'UnsupportedOrderType', INSUFFICIENT_VALID_TO = 'InsufficientValidTo', EXCESSIVE_VALID_TO = 'ExcessiveValidTo', TRANSFER_ETH_TO_CONTRACT = 'TransferEthToContract', - INVALID_NATIVE_SELL_TOKEN = 'InvalidNativeSellToken', - SAME_BUY_AND_SELL_TOKEN = 'SameBuyAndSellToken', + INVALID_NATIVE_SELL_TOKEN_SAME_BUY_AND_SELL_TOKEN = 'InvalidNativeSellToken SameBuyAndSellToken', UNSUPPORTED_SIGNATURE = 'UnsupportedSignature', - TOO_MANY_LIMIT_ORDERS= 'TooManyLimitOrders', - INVALID_APP_DATA = 'InvalidAppData', UNSUPPORTED_TOKEN = 'UnsupportedToken', - UNSUPPORTED_CUSTOM_INTERACTION = 'UnsupportedCustomInteraction', + UNSUPPORTED_CUSTOM_INTERACTION_INVALID_APP_DATA = 'UnsupportedCustomInteraction InvalidAppData', APP_DATA_HASH_MISMATCH = 'AppDataHashMismatch', } diff --git a/src/subgraph/api.ts b/src/subgraph/api.ts index f4a3a001..9bf11dc1 100644 --- a/src/subgraph/api.ts +++ b/src/subgraph/api.ts @@ -18,6 +18,7 @@ export const SUBGRAPH_PROD_CONFIG: ApiBaseUrls = { [SupportedChainId.MAINNET]: SUBGRAPH_BASE_URL + '/cow', [SupportedChainId.GNOSIS_CHAIN]: SUBGRAPH_BASE_URL + '/cow-gc', [SupportedChainId.GOERLI]: SUBGRAPH_BASE_URL + '/cow-goerli', + [SupportedChainId.SEPOLIA]: '', } /** @@ -30,6 +31,7 @@ export const SUBGRAPH_STAGING_CONFIG: ApiBaseUrls = { [SupportedChainId.MAINNET]: SUBGRAPH_BASE_URL + '/cow-staging', [SupportedChainId.GNOSIS_CHAIN]: SUBGRAPH_BASE_URL + '/cow-gc-staging', [SupportedChainId.GOERLI]: '', + [SupportedChainId.SEPOLIA]: '', } /**