@cowprotocol/sdk-contracts-ts 0.1.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.
package/README.md ADDED
@@ -0,0 +1,85 @@
1
+ <p align="center">
2
+ <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" />
3
+ </p>
4
+
5
+ # SDK Contracts
6
+
7
+ This package provides TypeScript contract interfaces and utilities for interacting with CoW Protocol smart contracts. It includes type-safe contract wrappers and helper functions for all CoW Protocol contracts.
8
+
9
+ ## Package Origin
10
+
11
+ This package represents a migration and modularization of the TypeScript utilities that were previously located in the [contracts repository](https://github.com/cowprotocol/contracts/tree/main/src/ts). The contract interaction logic has been extracted from the main contracts repository and reorganized into this dedicated SDK package to:
12
+
13
+ - **Improve modularity** - Separate smart contract deployment code from client-side interaction utilities
14
+ - **Enable independent versioning** - Allow contract interfaces to evolve independently from contract deployments
15
+ - **Better developer experience** - Provide a focused package specifically for TypeScript developers
16
+ - **SDK integration** - Seamlessly integrate with the broader CoW Protocol SDK ecosystem
17
+
18
+ ## What's included
19
+
20
+ - **Contract Interfaces** - TypeScript interfaces for all CoW Protocol smart contracts
21
+ - **Contract Utilities** - Helper functions for contract interactions
22
+ - **Type Safety** - Full TypeScript support with proper typing
23
+ - **Multi-Chain Support** - Contract addresses and interfaces for all supported chains
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @cowprotocol/sdk-contracts-ts
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```typescript
34
+ import { ContractsTs } from '@cowprotocol/sdk-contracts-ts'
35
+ import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
36
+ import { JsonRpcProvider, Wallet } from 'ethers'
37
+
38
+ // Configure the adapter
39
+ const provider = new JsonRpcProvider('YOUR_RPC_URL')
40
+ const wallet = new Wallet('YOUR_PRIVATE_KEY', provider)
41
+ const adapter = new EthersV6Adapter({ provider, signer: wallet })
42
+
43
+ // Initialize contracts with adapter
44
+ const contracts = new ContractsTs(adapter)
45
+
46
+ // Use contract interfaces
47
+ const settlementContract = contracts.settlement()
48
+ const vaultRelayerContract = contracts.vaultRelayer()
49
+ ```
50
+
51
+ ### Usage with CoW SDK
52
+
53
+ When using the CoW SDK, contract utilities are automatically available:
54
+
55
+ ```typescript
56
+ import {
57
+ CowSdk,
58
+ } from '@cowprotocol/cow-sdk'
59
+ import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
60
+ import { JsonRpcProvider, Wallet } from 'ethers'
61
+
62
+ // Configure the adapter
63
+ const provider = new JsonRpcProvider('YOUR_RPC_URL')
64
+ const wallet = new Wallet('YOUR_PRIVATE_KEY', provider)
65
+ const adapter = new EthersV6Adapter({ provider, signer: wallet })
66
+
67
+ // Initialize the unified SDK
68
+ const sdk = new CowSdk({
69
+ chainId: SupportedChainId.SEPOLIA,
70
+ adapter,
71
+ })
72
+
73
+ // Access contracts through the SDK
74
+ const settlementContract = sdk.contracts.settlement()
75
+ const vaultRelayerContract = sdk.contracts.vaultRelayer()
76
+ ```
77
+
78
+ ## Available Contracts
79
+
80
+ - **Settlement Contract** - Main CoW Protocol settlement contract
81
+ - **Vault Relayer** - Contract for handling vault interactions
82
+ - **Composable CoW** - Contract for conditional orders
83
+ - **Extensible Fallback Handler** - Safe fallback handler for smart contract wallets
84
+
85
+ > **Note:** This package is primarily designed to provide contract interfaces and is rarely used standalone. Most developers should use `@cowprotocol/cow-sdk` package which includes all contract utilities with proper adapter configuration.