@cowprotocol/cow-sdk 6.0.0-RC.9 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +3 -1
  2. package/dist/README.md +3 -1
  3. package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +87 -63
  4. package/dist/bridging/BridgingSdk/findBridgeProviderFromHook.d.ts +2 -0
  5. package/dist/bridging/BridgingSdk/getBridgeSignedHook.d.ts +8 -0
  6. package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +16 -0
  7. package/dist/bridging/BridgingSdk/getQuoteWithBridge.d.ts +3 -0
  8. package/dist/bridging/BridgingSdk/getQuoteWithoutBridge.d.ts +7 -7
  9. package/dist/bridging/BridgingSdk/mock/bridgeRequestMocks.d.ts +20 -0
  10. package/dist/bridging/BridgingSdk/types.d.ts +43 -0
  11. package/dist/bridging/const.d.ts +4 -2
  12. package/dist/bridging/errors.d.ts +22 -0
  13. package/dist/bridging/index.d.ts +8 -5
  14. package/dist/bridging/providers/across/AcrossApi.d.ts +30 -195
  15. package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +44 -41
  16. package/dist/bridging/providers/across/abi.d.ts +154 -154
  17. package/dist/bridging/providers/across/const/contracts.d.ts +3 -3
  18. package/dist/bridging/providers/across/const/interfaces.d.ts +3 -0
  19. package/dist/bridging/providers/across/const/misc.d.ts +2 -0
  20. package/dist/bridging/providers/across/const/tokens.d.ts +11 -11
  21. package/dist/bridging/providers/across/createAcrossDepositCall.d.ts +9 -9
  22. package/dist/bridging/providers/across/getDepositParams.d.ts +4 -0
  23. package/dist/bridging/providers/across/types.d.ts +242 -0
  24. package/dist/bridging/providers/across/util.d.ts +43 -39
  25. package/dist/bridging/providers/bungee/BungeeApi.d.ts +67 -0
  26. package/dist/bridging/providers/bungee/BungeeBridgeProvider.d.ts +44 -0
  27. package/dist/bridging/providers/bungee/abi.d.ts +203 -0
  28. package/dist/bridging/providers/bungee/const/contracts.d.ts +4 -0
  29. package/dist/bridging/providers/bungee/const/misc.d.ts +8 -0
  30. package/dist/bridging/providers/bungee/createBungeeDepositCall.d.ts +7 -0
  31. package/dist/bridging/providers/bungee/getBridgingStatusFromEvents.d.ts +3 -0
  32. package/dist/bridging/providers/bungee/types.d.ts +267 -0
  33. package/dist/bridging/providers/bungee/util.d.ts +62 -0
  34. package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +26 -20
  35. package/dist/bridging/providers/utils/getGasLimitEstimationForHook.d.ts +4 -0
  36. package/dist/bridging/types.d.ts +323 -251
  37. package/dist/bridging/utils.d.ts +9 -6
  38. package/dist/chains/const/index.d.ts +25 -25
  39. package/dist/chains/const/path.d.ts +1 -1
  40. package/dist/chains/details/arbitrum.d.ts +7 -7
  41. package/dist/chains/details/avalanche.d.ts +2 -0
  42. package/dist/chains/details/base.d.ts +7 -7
  43. package/dist/chains/details/gnosis.d.ts +7 -7
  44. package/dist/chains/details/index.d.ts +8 -0
  45. package/dist/chains/details/mainnet.d.ts +7 -7
  46. package/dist/chains/details/optimism.d.ts +2 -2
  47. package/dist/chains/details/polygon.d.ts +2 -2
  48. package/dist/chains/details/sepolia.d.ts +7 -7
  49. package/dist/chains/index.d.ts +4 -3
  50. package/dist/chains/types.d.ts +127 -122
  51. package/dist/chains/utils.d.ts +18 -18
  52. package/dist/common/consts/config.d.ts +9 -9
  53. package/dist/common/consts/contracts.d.ts +43 -34
  54. package/dist/common/consts/ipfs.d.ts +2 -2
  55. package/dist/common/consts/order.d.ts +1 -0
  56. package/dist/common/consts/path.d.ts +1 -1
  57. package/dist/common/consts/tokens.d.ts +9 -9
  58. package/dist/common/generated/CoWShed.d.ts +219 -219
  59. package/dist/common/generated/CoWShedFactory.d.ts +191 -191
  60. package/dist/common/generated/ComposableCoW.d.ts +340 -340
  61. package/dist/common/generated/EthFlow.d.ts +117 -117
  62. package/dist/common/generated/ExtensibleFallbackHandler.d.ts +282 -282
  63. package/dist/common/generated/GPv2Settlement.d.ts +107 -107
  64. package/dist/common/generated/TWAP.d.ts +141 -141
  65. package/dist/common/generated/common.d.ts +21 -21
  66. package/dist/common/generated/factories/CoWShedFactory__factory.d.ts +250 -250
  67. package/dist/common/generated/factories/CoWShed__factory.d.ts +254 -254
  68. package/dist/common/generated/factories/ComposableCoW__factory.d.ts +475 -475
  69. package/dist/common/generated/factories/EthFlow__factory.d.ts +124 -124
  70. package/dist/common/generated/factories/ExtensibleFallbackHandler__factory.d.ts +389 -389
  71. package/dist/common/generated/factories/GPv2Settlement__factory.d.ts +81 -81
  72. package/dist/common/generated/factories/TWAP__factory.d.ts +260 -260
  73. package/dist/common/generated/factories/index.d.ts +7 -7
  74. package/dist/common/generated/index.d.ts +15 -15
  75. package/dist/common/index.d.ts +12 -10
  76. package/dist/common/types/config.d.ts +70 -70
  77. package/dist/common/types/cow-error.d.ts +4 -4
  78. package/dist/common/types/ethereum.d.ts +5 -5
  79. package/dist/common/types/tokens.d.ts +12 -12
  80. package/dist/common/types/wallets.d.ts +5 -5
  81. package/dist/common/utils/common.d.ts +1 -0
  82. package/dist/common/utils/config.d.ts +4 -4
  83. package/dist/common/utils/log.d.ts +2 -0
  84. package/dist/common/utils/math.d.ts +19 -0
  85. package/dist/common/utils/order.d.ts +4 -0
  86. package/dist/common/utils/serialize.d.ts +1 -1
  87. package/dist/common/utils/wallet.d.ts +3 -3
  88. package/dist/composable/ConditionalOrder.d.ts +206 -206
  89. package/dist/composable/ConditionalOrderFactory.d.ts +19 -19
  90. package/dist/composable/Multiplexer.d.ts +174 -174
  91. package/dist/composable/contracts.d.ts +6 -6
  92. package/dist/composable/generated/ComposableCoW.d.ts +340 -340
  93. package/dist/composable/generated/ExtensibleFallbackHandler.d.ts +282 -282
  94. package/dist/composable/generated/TWAP.d.ts +141 -141
  95. package/dist/composable/generated/common.d.ts +21 -21
  96. package/dist/composable/generated/factories/ComposableCoW__factory.d.ts +475 -475
  97. package/dist/composable/generated/factories/ExtensibleFallbackHandler__factory.d.ts +389 -389
  98. package/dist/composable/generated/factories/TWAP__factory.d.ts +260 -260
  99. package/dist/composable/generated/factories/index.d.ts +3 -3
  100. package/dist/composable/generated/index.d.ts +7 -7
  101. package/dist/composable/index.d.ts +6 -6
  102. package/dist/composable/orderTypes/Twap.d.ts +242 -242
  103. package/dist/composable/orderTypes/index.d.ts +3 -3
  104. package/dist/composable/orderTypes/test/TestConditionalOrder.d.ts +25 -25
  105. package/dist/composable/types.d.ts +133 -133
  106. package/dist/composable/utils.d.ts +37 -37
  107. package/dist/cow-shed/CowShedSdk.d.ts +74 -69
  108. package/dist/cow-shed/contracts/CoWShedHooks.d.ts +47 -45
  109. package/dist/cow-shed/contracts/utils.d.ts +4 -4
  110. package/dist/cow-shed/index.d.ts +3 -2
  111. package/dist/cow-shed/types.d.ts +17 -17
  112. package/dist/hooks/utils.d.ts +3 -2
  113. package/dist/index-847d9333.js +29 -0
  114. package/dist/index-847d9333.js.map +1 -0
  115. package/dist/index.d.ts +11 -10
  116. package/dist/index.js +4 -4
  117. package/dist/index.js.map +1 -1
  118. package/dist/index.modern.mjs +1 -1
  119. package/dist/index.module.js +4 -4
  120. package/dist/index.module.js.map +1 -1
  121. package/dist/order-book/api.d.ts +235 -235
  122. package/dist/order-book/generated/index.d.ts +55 -55
  123. package/dist/order-book/generated/models/Address.d.ts +4 -4
  124. package/dist/order-book/generated/models/AppData.d.ts +7 -7
  125. package/dist/order-book/generated/models/AppDataHash.d.ts +6 -6
  126. package/dist/order-book/generated/models/AppDataObject.d.ts +7 -7
  127. package/dist/order-book/generated/models/Auction.d.ts +30 -30
  128. package/dist/order-book/generated/models/AuctionOrder.d.ts +92 -92
  129. package/dist/order-book/generated/models/AuctionPrices.d.ts +6 -6
  130. package/dist/order-book/generated/models/BigUint.d.ts +4 -4
  131. package/dist/order-book/generated/models/BuyTokenDestination.d.ts +7 -7
  132. package/dist/order-book/generated/models/CallData.d.ts +4 -4
  133. package/dist/order-book/generated/models/CompetitionAuction.d.ts +14 -14
  134. package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +29 -29
  135. package/dist/order-book/generated/models/EcdsaSignature.d.ts +4 -4
  136. package/dist/order-book/generated/models/EcdsaSigningScheme.d.ts +7 -7
  137. package/dist/order-book/generated/models/EthflowData.d.ts +20 -20
  138. package/dist/order-book/generated/models/ExecutedAmounts.d.ts +5 -5
  139. package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +8 -8
  140. package/dist/order-book/generated/models/FeePolicy.d.ts +7 -7
  141. package/dist/order-book/generated/models/InteractionData.d.ts +11 -11
  142. package/dist/order-book/generated/models/NativePriceResponse.d.ts +10 -10
  143. package/dist/order-book/generated/models/OnchainOrderData.d.ts +24 -24
  144. package/dist/order-book/generated/models/Order.d.ts +3 -3
  145. package/dist/order-book/generated/models/OrderCancellation.d.ts +14 -14
  146. package/dist/order-book/generated/models/OrderCancellationError.d.ts +15 -15
  147. package/dist/order-book/generated/models/OrderCancellations.d.ts +18 -18
  148. package/dist/order-book/generated/models/OrderClass.d.ts +8 -8
  149. package/dist/order-book/generated/models/OrderCreation.d.ts +80 -80
  150. package/dist/order-book/generated/models/OrderKind.d.ts +7 -7
  151. package/dist/order-book/generated/models/OrderMetaData.d.ts +100 -100
  152. package/dist/order-book/generated/models/OrderParameters.d.ts +53 -53
  153. package/dist/order-book/generated/models/OrderPostError.d.ts +35 -35
  154. package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +58 -58
  155. package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +27 -27
  156. package/dist/order-book/generated/models/OrderQuoteSide.d.ts +26 -26
  157. package/dist/order-book/generated/models/OrderQuoteSideKindBuy.d.ts +3 -3
  158. package/dist/order-book/generated/models/OrderQuoteSideKindSell.d.ts +3 -3
  159. package/dist/order-book/generated/models/OrderQuoteValidity.d.ts +14 -14
  160. package/dist/order-book/generated/models/OrderStatus.d.ts +10 -10
  161. package/dist/order-book/generated/models/PreSignature.d.ts +4 -4
  162. package/dist/order-book/generated/models/PriceEstimationError.d.ts +12 -12
  163. package/dist/order-book/generated/models/PriceImprovement.d.ts +12 -12
  164. package/dist/order-book/generated/models/PriceQuality.d.ts +16 -16
  165. package/dist/order-book/generated/models/Quote.d.ts +19 -19
  166. package/dist/order-book/generated/models/SellTokenSource.d.ts +8 -8
  167. package/dist/order-book/generated/models/Signature.d.ts +6 -6
  168. package/dist/order-book/generated/models/SigningScheme.d.ts +9 -9
  169. package/dist/order-book/generated/models/SolverCompetitionResponse.d.ts +30 -30
  170. package/dist/order-book/generated/models/SolverSettlement.d.ts +47 -47
  171. package/dist/order-book/generated/models/Surplus.d.ts +7 -7
  172. package/dist/order-book/generated/models/TokenAmount.d.ts +4 -4
  173. package/dist/order-book/generated/models/TotalSurplus.d.ts +10 -10
  174. package/dist/order-book/generated/models/Trade.d.ts +57 -57
  175. package/dist/order-book/generated/models/TransactionHash.d.ts +4 -4
  176. package/dist/order-book/generated/models/UID.d.ts +8 -8
  177. package/dist/order-book/generated/models/Volume.d.ts +6 -6
  178. package/dist/order-book/index.d.ts +5 -5
  179. package/dist/order-book/mock.d.ts +63 -63
  180. package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +35 -22
  181. package/dist/order-book/request.d.ts +49 -49
  182. package/dist/order-book/transformOrder.d.ts +10 -10
  183. package/dist/order-book/types.d.ts +74 -74
  184. package/dist/order-signing/index.d.ts +2 -2
  185. package/dist/order-signing/orderSigningUtils.d.ts +97 -97
  186. package/dist/order-signing/types.d.ts +55 -55
  187. package/dist/order-signing/utils.d.ts +49 -49
  188. package/dist/package.json +31 -32
  189. package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +151 -12
  190. package/dist/schemas/trading/LimitTradeParameters.ts +136 -15
  191. package/dist/schemas/trading/QuoteResultsSerialized.ts +292 -27
  192. package/dist/schemas/trading/QuoterParameters.ts +10 -0
  193. package/dist/schemas/trading/SwapAdvancedSettings.ts +331 -12
  194. package/dist/schemas/trading/TradeParameters.ts +136 -15
  195. package/dist/src/trading/README.md +99 -7
  196. package/dist/subgraph/api.d.ts +77 -77
  197. package/dist/subgraph/graphql.d.ts +3203 -3203
  198. package/dist/subgraph/index.d.ts +1 -1
  199. package/dist/subgraph/queries.d.ts +14 -14
  200. package/dist/test/utils.d.ts +1 -0
  201. package/dist/trading/appDataUtils.d.ts +5 -4
  202. package/dist/trading/calculateUniqueOrderId.d.ts +5 -5
  203. package/dist/trading/consts.d.ts +6 -14
  204. package/dist/trading/getEthFlowTransaction.d.ts +12 -7
  205. package/dist/trading/getOrderToSign.d.ts +11 -8
  206. package/dist/trading/getOrderTypedData.d.ts +4 -4
  207. package/dist/trading/getPreSignTransaction.d.ts +4 -4
  208. package/dist/trading/getQuote.d.ts +26 -14
  209. package/dist/trading/index.d.ts +21 -19
  210. package/dist/trading/postCoWProtocolTrade.d.ts +4 -4
  211. package/dist/trading/postLimitOrder.d.ts +3 -3
  212. package/dist/trading/postSellNativeCurrencyOrder.d.ts +4 -7
  213. package/dist/trading/postSwapOrder.d.ts +5 -5
  214. package/dist/trading/suggestSlippageBps.d.ts +13 -0
  215. package/dist/trading/suggestSlippageFromFee.d.ts +19 -0
  216. package/dist/trading/suggestSlippageFromVolume.d.ts +10 -0
  217. package/dist/trading/tradingSdk.d.ts +26 -26
  218. package/dist/trading/types.d.ts +221 -190
  219. package/dist/trading/utils/getPartnerFeeBps.d.ts +2 -0
  220. package/dist/trading/{utils.d.ts → utils/misc.d.ts} +27 -27
  221. package/dist/trading/utils/slippage.d.ts +16 -0
  222. package/dist/utils-09dadb80.js +2 -0
  223. package/dist/utils-09dadb80.js.map +1 -0
  224. package/dist/utils-0ff3f95e.js +2 -0
  225. package/dist/utils-0ff3f95e.js.map +1 -0
  226. package/dist/utils-ddcfac77.js +2 -0
  227. package/dist/utils-ddcfac77.js.map +1 -0
  228. package/dist/utils.d.ts +3 -3
  229. package/dist/weiroll/index.d.ts +23 -23
  230. package/package.json +31 -32
  231. package/dist/bridging/BridgingSdk/getErc20Decimals.d.ts +0 -4
  232. package/dist/bridging/BridgingSdk/getQuoteWithBridging.d.ts +0 -9
  233. package/dist/index-317c25f1.js +0 -29
  234. package/dist/index-317c25f1.js.map +0 -1
  235. package/dist/utils-204a9cbe.js +0 -2
  236. package/dist/utils-204a9cbe.js.map +0 -1
  237. package/dist/utils-762ee9c3.js +0 -2
  238. package/dist/utils-762ee9c3.js.map +0 -1
  239. package/dist/utils-de2eb543.js +0 -2
  240. package/dist/utils-de2eb543.js.map +0 -1
@@ -1,97 +1,97 @@
1
- import type { SupportedChainId } from '../chains';
2
- import type { Signer } from '@ethersproject/abstract-signer';
3
- import type { Order, TypedDataDomain, OrderUidParams } from '@cowprotocol/contracts';
4
- import type { SigningResult, UnsignedOrder } from './types';
5
- /**
6
- * Utility class for signing order intents and cancellations.
7
- *
8
- * @remarks This class only supports `eth_sign` and wallet-native EIP-712 signing. For use of
9
- * `presign` and `eip1271` {@link https://docs.cow.fi/ | see the docs}.
10
- * @example
11
- *
12
- * ```typescript
13
- * import { OrderSigningUtils, SupportedChainId, UnsignedOrder } from '@cowprotocol/cow-sdk'
14
- * import { Web3Provider } from '@ethersproject/providers'
15
- *
16
- * const account = 'YOUR_WALLET_ADDRESS'
17
- * const chainId = 100 // Gnosis chain
18
- * const provider = new Web3Provider(window.ethereum)
19
- * const signer = provider.getSigner()
20
- *
21
- * async function main() {
22
- * const orderToSign: UnsignedOrder = { ... }
23
- * const orderSigningResult = await OrderSigningUtils.signOrder(orderToSign, chainId, signer)
24
- *
25
- * const orderId = await orderBookApi.sendOrder({ ...orderToSign, ...orderSigningResult })
26
- *
27
- * const order = await orderBookApi.getOrder(orderId)
28
- *
29
- * const trades = await orderBookApi.getTrades({ orderId })
30
- *
31
- * const orderCancellationSigningResult = await OrderSigningUtils.signOrderCancellations([orderId], chainId, signer)
32
- *
33
- * const cancellationResult = await orderBookApi.sendSignedOrderCancellations({...orderCancellationSigningResult, orderUids: [orderId] })
34
- *
35
- * console.log('Results: ', { orderId, order, trades, orderCancellationSigningResult, cancellationResult })
36
- * }
37
- * ```
38
- */
39
- export declare class OrderSigningUtils {
40
- /**
41
- * Sign the order intent with the specified signer.
42
- *
43
- * @remarks If the API reports an error with the signature, it is likely to be due to an incorrectly
44
- * specified `chainId`. Please ensure that the `chainId` is correct for the network you are
45
- * using.
46
- * @param {UnsignedOrder} order The unsigned order intent to be placed.
47
- * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
48
- * @param {Signer} signer The signer who is placing the order intent.
49
- * @returns {Promise<SigningResult>} Encoded signature including signing scheme for the order.
50
- */
51
- static signOrder(order: UnsignedOrder, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
52
- /**
53
- * Sign a cancellation message of an order intent with the specified signer.
54
- * @param {string} orderUid The unique identifier of the order to cancel.
55
- * @param {SupportedChainId} chainId The CoW Protocol `chainid` context that's being used.
56
- * @param {Signer} signer The signer who initially placed the order intent.
57
- * @returns {Promise<SigningResult>} Encoded signature including signing scheme for the cancellation.
58
- */
59
- static signOrderCancellation(orderUid: string, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
60
- /**
61
- * Sign a cancellation message of multiple order intents with the specified signer.
62
- * @param {string[]} orderUids An array of `orderUid` to cancel.
63
- * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
64
- * @param {Signer} signer The signer who initially placed the order intents.
65
- * @returns {Promise<SigningResult>} Encoded signature including signing scheme for the cancellation.
66
- */
67
- static signOrderCancellations(orderUids: string[], chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
68
- /**
69
- * Get the EIP-712 typed domain data being used for signing.
70
- * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
71
- * @return The EIP-712 typed domain data.
72
- * @see https://eips.ethereum.org/EIPS/eip-712
73
- */
74
- static getDomain(chainId: SupportedChainId): Promise<TypedDataDomain>;
75
- /**
76
- * Hashes the order intent and generate deterministic order ID.
77
- * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
78
- * @param {Order} order order to sign
79
- * @param {Pick<OrderUidParams, 'owner'>} params order unique identifier parameters.
80
- */
81
- static generateOrderId(chainId: SupportedChainId, order: Order, params: Pick<OrderUidParams, 'owner'>): Promise<{
82
- orderId: string;
83
- orderDigest: string;
84
- }>;
85
- /**
86
- * Get the domain separator hash for the EIP-712 typed domain data being used for signing.
87
- * @param chainId {SupportedChainId} chainId The CoW Protocol protocol `chainId` context that's being used.
88
- * @returns A string representation of the EIP-712 typed domain data hash.
89
- */
90
- static getDomainSeparator(chainId: SupportedChainId): Promise<string>;
91
- /**
92
- * Get the EIP-712 types used for signing a GPv2Order.Data struct. This is useful for when
93
- * signing orders using smart contracts, whereby this SDK cannot do the EIP-1271 signing for you.
94
- * @returns The EIP-712 types used for signing.
95
- */
96
- static getEIP712Types(): Record<string, unknown>;
97
- }
1
+ import type { SupportedChainId } from '../chains';
2
+ import type { Signer } from '@ethersproject/abstract-signer';
3
+ import type { Order, TypedDataDomain, OrderUidParams } from '@cowprotocol/contracts';
4
+ import type { SigningResult, UnsignedOrder } from './types';
5
+ /**
6
+ * Utility class for signing order intents and cancellations.
7
+ *
8
+ * @remarks This class only supports `eth_sign` and wallet-native EIP-712 signing. For use of
9
+ * `presign` and `eip1271` {@link https://docs.cow.fi/ | see the docs}.
10
+ * @example
11
+ *
12
+ * ```typescript
13
+ * import { OrderSigningUtils, SupportedChainId, UnsignedOrder } from '@cowprotocol/cow-sdk'
14
+ * import { Web3Provider } from '@ethersproject/providers'
15
+ *
16
+ * const account = 'YOUR_WALLET_ADDRESS'
17
+ * const chainId = 100 // Gnosis chain
18
+ * const provider = new Web3Provider(window.ethereum)
19
+ * const signer = provider.getSigner()
20
+ *
21
+ * async function main() {
22
+ * const orderToSign: UnsignedOrder = { ... }
23
+ * const orderSigningResult = await OrderSigningUtils.signOrder(orderToSign, chainId, signer)
24
+ *
25
+ * const orderId = await orderBookApi.sendOrder({ ...orderToSign, ...orderSigningResult })
26
+ *
27
+ * const order = await orderBookApi.getOrder(orderId)
28
+ *
29
+ * const trades = await orderBookApi.getTrades({ orderId })
30
+ *
31
+ * const orderCancellationSigningResult = await OrderSigningUtils.signOrderCancellations([orderId], chainId, signer)
32
+ *
33
+ * const cancellationResult = await orderBookApi.sendSignedOrderCancellations({...orderCancellationSigningResult, orderUids: [orderId] })
34
+ *
35
+ * console.log('Results: ', { orderId, order, trades, orderCancellationSigningResult, cancellationResult })
36
+ * }
37
+ * ```
38
+ */
39
+ export declare class OrderSigningUtils {
40
+ /**
41
+ * Sign the order intent with the specified signer.
42
+ *
43
+ * @remarks If the API reports an error with the signature, it is likely to be due to an incorrectly
44
+ * specified `chainId`. Please ensure that the `chainId` is correct for the network you are
45
+ * using.
46
+ * @param {UnsignedOrder} order The unsigned order intent to be placed.
47
+ * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
48
+ * @param {Signer} signer The signer who is placing the order intent.
49
+ * @returns {Promise<SigningResult>} Encoded signature including signing scheme for the order.
50
+ */
51
+ static signOrder(order: UnsignedOrder, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
52
+ /**
53
+ * Sign a cancellation message of an order intent with the specified signer.
54
+ * @param {string} orderUid The unique identifier of the order to cancel.
55
+ * @param {SupportedChainId} chainId The CoW Protocol `chainid` context that's being used.
56
+ * @param {Signer} signer The signer who initially placed the order intent.
57
+ * @returns {Promise<SigningResult>} Encoded signature including signing scheme for the cancellation.
58
+ */
59
+ static signOrderCancellation(orderUid: string, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
60
+ /**
61
+ * Sign a cancellation message of multiple order intents with the specified signer.
62
+ * @param {string[]} orderUids An array of `orderUid` to cancel.
63
+ * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
64
+ * @param {Signer} signer The signer who initially placed the order intents.
65
+ * @returns {Promise<SigningResult>} Encoded signature including signing scheme for the cancellation.
66
+ */
67
+ static signOrderCancellations(orderUids: string[], chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
68
+ /**
69
+ * Get the EIP-712 typed domain data being used for signing.
70
+ * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
71
+ * @return The EIP-712 typed domain data.
72
+ * @see https://eips.ethereum.org/EIPS/eip-712
73
+ */
74
+ static getDomain(chainId: SupportedChainId): Promise<TypedDataDomain>;
75
+ /**
76
+ * Hashes the order intent and generate deterministic order ID.
77
+ * @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
78
+ * @param {Order} order order to sign
79
+ * @param {Pick<OrderUidParams, 'owner'>} params order unique identifier parameters.
80
+ */
81
+ static generateOrderId(chainId: SupportedChainId, order: Order, params: Pick<OrderUidParams, 'owner'>): Promise<{
82
+ orderId: string;
83
+ orderDigest: string;
84
+ }>;
85
+ /**
86
+ * Get the domain separator hash for the EIP-712 typed domain data being used for signing.
87
+ * @param chainId {SupportedChainId} chainId The CoW Protocol protocol `chainId` context that's being used.
88
+ * @returns A string representation of the EIP-712 typed domain data hash.
89
+ */
90
+ static getDomainSeparator(chainId: SupportedChainId): Promise<string>;
91
+ /**
92
+ * Get the EIP-712 types used for signing a GPv2Order.Data struct. This is useful for when
93
+ * signing orders using smart contracts, whereby this SDK cannot do the EIP-1271 signing for you.
94
+ * @returns The EIP-712 types used for signing.
95
+ */
96
+ static getEIP712Types(): Record<string, unknown>;
97
+ }
@@ -1,55 +1,55 @@
1
- import type { SupportedChainId } from '../chains';
2
- import type { Signer } from '@ethersproject/abstract-signer';
3
- import type { OrderParameters, EcdsaSigningScheme } from '../order-book';
4
- /**
5
- * Unsigned order intent to be placed.
6
- */
7
- export type UnsignedOrder = Omit<OrderParameters, 'receiver'> & {
8
- receiver: string;
9
- };
10
- /**
11
- * Encoded signature including signing scheme for the order.
12
- */
13
- export type SigningResult = {
14
- signature: string;
15
- signingScheme: EcdsaSigningScheme;
16
- };
17
- /**
18
- * Parameters for signing an order intent.
19
- * @param chainId The CoW Protocol `chainId` context that's being used.
20
- * @param signer The signer who is placing the order intent.
21
- * @param order The unsigned order intent to be placed.
22
- * @param signingScheme The signing scheme to use for the signature.
23
- */
24
- export interface SignOrderParams {
25
- chainId: SupportedChainId;
26
- signer: Signer;
27
- order: UnsignedOrder;
28
- signingScheme: EcdsaSigningScheme;
29
- }
30
- /**
31
- * Parameters for signing an order cancellation.
32
- * @param chainId The CoW Protocol `chainId` context that's being used.
33
- * @param signer The signer who initially placed the order intent.
34
- * @param orderUid The unique identifier of the order to cancel.
35
- * @param signingScheme The signing scheme to use for the signature.
36
- */
37
- export interface SignOrderCancellationParams {
38
- chainId: SupportedChainId;
39
- signer: Signer;
40
- orderUid: string;
41
- signingScheme: EcdsaSigningScheme;
42
- }
43
- /**
44
- * Parameters for signing multiple bulk order cancellations.
45
- * @param chainId The CoW Protocol `chainId` context that's being used.
46
- * @param signer The signer who initially placed the order intents.
47
- * @param orderUids An array of `orderUid` to cancel.
48
- * @param signingScheme The signing scheme to use for the signature.
49
- */
50
- export interface SignOrderCancellationsParams {
51
- chainId: SupportedChainId;
52
- signer: Signer;
53
- orderUids: string[];
54
- signingScheme: EcdsaSigningScheme;
55
- }
1
+ import type { SupportedChainId } from '../chains';
2
+ import type { Signer } from '@ethersproject/abstract-signer';
3
+ import type { OrderParameters, EcdsaSigningScheme } from '../order-book';
4
+ /**
5
+ * Unsigned order intent to be placed.
6
+ */
7
+ export type UnsignedOrder = Omit<OrderParameters, 'receiver'> & {
8
+ receiver: string;
9
+ };
10
+ /**
11
+ * Encoded signature including signing scheme for the order.
12
+ */
13
+ export type SigningResult = {
14
+ signature: string;
15
+ signingScheme: EcdsaSigningScheme;
16
+ };
17
+ /**
18
+ * Parameters for signing an order intent.
19
+ * @param chainId The CoW Protocol `chainId` context that's being used.
20
+ * @param signer The signer who is placing the order intent.
21
+ * @param order The unsigned order intent to be placed.
22
+ * @param signingScheme The signing scheme to use for the signature.
23
+ */
24
+ export interface SignOrderParams {
25
+ chainId: SupportedChainId;
26
+ signer: Signer;
27
+ order: UnsignedOrder;
28
+ signingScheme: EcdsaSigningScheme;
29
+ }
30
+ /**
31
+ * Parameters for signing an order cancellation.
32
+ * @param chainId The CoW Protocol `chainId` context that's being used.
33
+ * @param signer The signer who initially placed the order intent.
34
+ * @param orderUid The unique identifier of the order to cancel.
35
+ * @param signingScheme The signing scheme to use for the signature.
36
+ */
37
+ export interface SignOrderCancellationParams {
38
+ chainId: SupportedChainId;
39
+ signer: Signer;
40
+ orderUid: string;
41
+ signingScheme: EcdsaSigningScheme;
42
+ }
43
+ /**
44
+ * Parameters for signing multiple bulk order cancellations.
45
+ * @param chainId The CoW Protocol `chainId` context that's being used.
46
+ * @param signer The signer who initially placed the order intents.
47
+ * @param orderUids An array of `orderUid` to cancel.
48
+ * @param signingScheme The signing scheme to use for the signature.
49
+ */
50
+ export interface SignOrderCancellationsParams {
51
+ chainId: SupportedChainId;
52
+ signer: Signer;
53
+ orderUids: string[];
54
+ signingScheme: EcdsaSigningScheme;
55
+ }
@@ -1,49 +1,49 @@
1
- import type { TypedDataDomain, Order, OrderUidParams } from '@cowprotocol/contracts';
2
- import type { Signer } from '@ethersproject/abstract-signer';
3
- import type { SigningResult, UnsignedOrder } from './types';
4
- import type { SupportedChainId } from '../chains';
5
- /**
6
- * Returns the signature for the specified order with the signing scheme encoded
7
- * into the signature.
8
- * @param {UnsignedOrder} order The order to sign.
9
- * @param {SupportedChainId} chainId The chain Id
10
- * @param {Signer} signer The owner for the order used to sign.
11
- * @return {*} Encoded signature including signing scheme for the order.
12
- */
13
- export declare function signOrder(order: UnsignedOrder, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
14
- /**
15
- * Returns the signature for the Order Cancellation with the signing scheme encoded
16
- * into the signature.
17
- * @param {string} orderUid The unique identifier of the order being cancelled.
18
- * @param {SupportedChainId} chainId The chain Id
19
- * @param {Signer} signer The owner for the order used to sign.
20
- * @return {*} Encoded signature including signing scheme for the order.
21
- */
22
- export declare function signOrderCancellation(orderUid: string, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
23
- /**
24
- * Returns the signature for the Order Cancellations with the signing scheme encoded
25
- * into the signature.
26
- *
27
- * @param {string[]} orderUids The unique identifiers of the orders being cancelled.
28
- * @param {SupportedChainId} chainId The CoW Protocol protocol `chainId` context that's being used.
29
- * @param {Signer} signer The owner that had placed the orders used to sign.
30
- * @returns {*} Encoded signature including signing scheme for the order.
31
- */
32
- export declare function signOrderCancellations(orderUids: string[], chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
33
- /**
34
- * Returns the TypedDataDomain used for signing for the specified chainId.
35
- * @param {SupportedChainId} chainId The chain Id
36
- * @return {*} The TypedDataDomain for the specified chainId.
37
- * @throws {CowError} If the chainId is not supported.
38
- */
39
- export declare function getDomain(chainId: SupportedChainId): TypedDataDomain;
40
- /**
41
- * Generate a deterministic order ID for the specified order.
42
- * @param {SupportedChainId} chainId The chain Id
43
- * @param {Order} order order to sign
44
- * @param {Pick<OrderUidParams, 'owner'>} params order unique identifier parameters.
45
- */
46
- export declare function generateOrderId(chainId: SupportedChainId, order: Order, params: Pick<OrderUidParams, 'owner'>): Promise<{
47
- orderId: string;
48
- orderDigest: string;
49
- }>;
1
+ import type { TypedDataDomain, Order, OrderUidParams } from '@cowprotocol/contracts';
2
+ import type { Signer } from '@ethersproject/abstract-signer';
3
+ import type { SigningResult, UnsignedOrder } from './types';
4
+ import type { SupportedChainId } from '../chains';
5
+ /**
6
+ * Returns the signature for the specified order with the signing scheme encoded
7
+ * into the signature.
8
+ * @param {UnsignedOrder} order The order to sign.
9
+ * @param {SupportedChainId} chainId The chain Id
10
+ * @param {Signer} signer The owner for the order used to sign.
11
+ * @return {*} Encoded signature including signing scheme for the order.
12
+ */
13
+ export declare function signOrder(order: UnsignedOrder, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
14
+ /**
15
+ * Returns the signature for the Order Cancellation with the signing scheme encoded
16
+ * into the signature.
17
+ * @param {string} orderUid The unique identifier of the order being cancelled.
18
+ * @param {SupportedChainId} chainId The chain Id
19
+ * @param {Signer} signer The owner for the order used to sign.
20
+ * @return {*} Encoded signature including signing scheme for the order.
21
+ */
22
+ export declare function signOrderCancellation(orderUid: string, chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
23
+ /**
24
+ * Returns the signature for the Order Cancellations with the signing scheme encoded
25
+ * into the signature.
26
+ *
27
+ * @param {string[]} orderUids The unique identifiers of the orders being cancelled.
28
+ * @param {SupportedChainId} chainId The CoW Protocol protocol `chainId` context that's being used.
29
+ * @param {Signer} signer The owner that had placed the orders used to sign.
30
+ * @returns {*} Encoded signature including signing scheme for the order.
31
+ */
32
+ export declare function signOrderCancellations(orderUids: string[], chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
33
+ /**
34
+ * Returns the TypedDataDomain used for signing for the specified chainId.
35
+ * @param {SupportedChainId} chainId The chain Id
36
+ * @return {*} The TypedDataDomain for the specified chainId.
37
+ * @throws {CowError} If the chainId is not supported.
38
+ */
39
+ export declare function getDomain(chainId: SupportedChainId): TypedDataDomain;
40
+ /**
41
+ * Generate a deterministic order ID for the specified order.
42
+ * @param {SupportedChainId} chainId The chain Id
43
+ * @param {Order} order order to sign
44
+ * @param {Pick<OrderUidParams, 'owner'>} params order unique identifier parameters.
45
+ */
46
+ export declare function generateOrderId(chainId: SupportedChainId, order: Order, params: Pick<OrderUidParams, 'owner'>): Promise<{
47
+ orderId: string;
48
+ orderDigest: string;
49
+ }>;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/cow-sdk",
3
- "version": "6.0.0-RC.9",
3
+ "version": "6.0.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "files": [
6
6
  "/dist"
@@ -19,7 +19,7 @@
19
19
  "start": "microbundle -f modern,esm,cjs watch",
20
20
  "copy-md-files": "npx cpx \"**/*.md\" dist",
21
21
  "postbuild": "cp package.json dist && yarn copy-md-files && yarn run trading:generateSchemas",
22
- "lint": "eslint src",
22
+ "lint": "eslint ./src",
23
23
  "format": "prettier --write \"src/**/*.+(ts|json)\"",
24
24
  "test": "jest",
25
25
  "test:coverage": "jest --coverage --json --outputFile=jest.results.json && cat ./coverage/lcov.info | coveralls",
@@ -33,14 +33,15 @@
33
33
  "trading:generateSchemas": "ts-node scripts/generateTradingSchemas.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@cowprotocol/app-data": "^2.4.0",
37
- "@cowprotocol/contracts": "^1.6.0",
38
- "@ethersproject/abstract-signer": "^5.7.0",
39
- "@openzeppelin/merkle-tree": "^1.0.5",
36
+ "@cowprotocol/app-data": "^3.2.0",
37
+ "@cowprotocol/contracts": "^1.8.0",
38
+ "@ethersproject/abstract-signer": "^5.8.0",
39
+ "@openzeppelin/merkle-tree": "^1.0.8",
40
40
  "@weiroll/weiroll.js": "^0.3.0",
41
- "cross-fetch": "^3.1.5",
42
- "exponential-backoff": "^3.1.1",
43
- "graphql": "^16.3.0",
41
+ "cross-fetch": "^3.2.0",
42
+ "deepmerge": "^4.3.1",
43
+ "exponential-backoff": "^3.1.2",
44
+ "graphql": "^16.11.0",
44
45
  "graphql-request": "^4.3.0",
45
46
  "limiter": "^3.0.0"
46
47
  },
@@ -50,37 +51,34 @@
50
51
  "devDependencies": {
51
52
  "@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
52
53
  "@babel/plugin-proposal-private-methods": "^7.18.6",
53
- "@babel/preset-env": "^7.20.2",
54
- "@babel/preset-typescript": "^7.18.6",
55
- "@graphql-codegen/cli": "3.0.0",
56
- "@graphql-codegen/typescript": "3.0.0",
57
- "@graphql-codegen/typescript-operations": "^3.0.0",
58
- "@typechain/ethers-v5": "^11.0.0",
59
- "@types/jest": "^29.4.0",
60
- "@types/node": "^22.9.0",
61
- "@typescript-eslint/eslint-plugin": "^5.51.0",
62
- "@typescript-eslint/parser": "^5.51.0",
54
+ "@babel/preset-env": "^7.27.2",
55
+ "@babel/preset-typescript": "^7.27.1",
56
+ "@eslint/js": "^9.26.0",
57
+ "@graphql-codegen/cli": "5.0.6",
58
+ "@graphql-codegen/typescript": "4.1.6",
59
+ "@graphql-codegen/typescript-operations": "^4.6.1",
60
+ "@typechain/ethers-v5": "^11.1.2",
61
+ "@types/jest": "^29.5.14",
62
+ "@types/node": "^22.15.17",
63
63
  "babel-plugin-inline-import": "^3.0.0",
64
64
  "coveralls": "^3.1.1",
65
65
  "cpx": "^1.5.0",
66
- "eslint": "^8.33.0",
67
- "eslint-config-prettier": "^8.6.0",
68
- "eslint-plugin-prettier": "^4.2.1",
69
- "eslint-plugin-unused-imports": "^3.0.0",
70
- "ethers": "^5.8.0",
71
- "jest": "^29.6.4",
66
+ "eslint": "^9.26.0",
67
+ "eslint-plugin-unused-imports": "^4.1.4",
68
+ "jest": "^29.7.0",
72
69
  "jest-fetch-mock": "^3.0.3",
73
70
  "microbundle": "^0.15.1",
74
- "openapi-typescript-codegen": "^0.23.0",
75
- "prettier": "^2.5.1",
76
- "ts-json-schema-generator": "^2.3.0",
71
+ "openapi-typescript-codegen": "^0.29.0",
72
+ "prettier": "^3.5.3",
73
+ "ts-json-schema-generator": "^2.4.0",
77
74
  "ts-mockito": "^2.6.1",
78
- "tsc-watch": "^6.0.0",
79
- "typechain": "^8.2.0",
80
- "typescript": "^4.9.5"
75
+ "ts-node": "^10.9.2",
76
+ "tsc-watch": "^6.2.1",
77
+ "typechain": "^8.3.2",
78
+ "typescript": "^5.8.3",
79
+ "typescript-eslint": "^8.32.1"
81
80
  },
82
81
  "jest": {
83
- "maxWorkers": 1,
84
82
  "automock": false,
85
83
  "resetMocks": false,
86
84
  "setupFiles": [
@@ -90,6 +88,7 @@
90
88
  "src/**/*.{ts,tsx}"
91
89
  ],
92
90
  "coveragePathIgnorePatterns": [
91
+ "src/common/generated",
93
92
  "src/composable/generated"
94
93
  ],
95
94
  "moduleDirectories": [