Class: Multiplexer
Multiplexer for conditional orders - using ComposableCoW!
This class provides functionality to:
- Generate a merkle tree of conditional orders
 - Generate proofs for all orders in the merkle tree
 - Save proofs, with the ability to omit / skip specific conditional orders
 - Support for passing an optional upload function to upload the proofs to a decentralized storage network
 
Constructors
constructor
• new Multiplexer(chain, orders?, root?, location?): Multiplexer
Parameters
| Name | Type | Default value | Description | 
|---|---|---|---|
chain | SupportedChainId | undefined | The chainId for where we're using ComposableCoW. | 
orders? | Orders | undefined | An optional array of conditional orders to initialize the merkle tree with. | 
root? | string | undefined | An optional root to verify against. | 
location | ProofLocation | ProofLocation.PRIVATE | The location of the proofs for the conditional orders. | 
Returns
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:42
Properties
chain
• chain: SupportedChainId
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:29
ctx
• Private Optional ctx: string
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:34
location
• location: ProofLocation
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:30
orders
• Private orders: Orders = {}
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:32
tree
• Private Optional tree: StandardMerkleTree<string[]>
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:33
orderTypeRegistry
▪ Static orderTypeRegistry: Record<string, (...args: unknown[]) => ConditionalOrder<unknown, unknown>> = {}
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:27
Accessors
orderIds
• get orderIds(): string[]
Get all the conditional order ids in the multiplexer.
Returns
string[]
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:226
root
• get root(): string
Returns
string
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:230
Methods
add
▸ add<T, P>(order): void
Add a conditional order to the merkle tree.
Type parameters
| Name | 
|---|
T | 
P | 
Parameters
| Name | Type | Description | 
|---|---|---|
order | ConditionalOrder<T, P> | The order to add to the merkle tree. | 
Returns
void
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:168
dumpProofs
▸ dumpProofs(filter?): string
The primary entry point for dumping the proofs and parameters for the conditional orders.
This is to be used by watchtowers / indexers to store the proofs and parameters for the
conditional orders off-chain. The encoding returned by this method may NOT contain all
proofs and parameters, depending on the filter provided, and therefore should not be used
to rehydrate the multiplexer from a user's perspective.
Parameters
| Name | Type | Description | 
|---|---|---|
filter? | (v: string[]) => boolean | getProofs | 
Returns
string
A JSON-encoded string of the proofs and parameters for the conditional orders.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:362
dumpProofsAndParams
▸ dumpProofsAndParams(filter?): ProofWithParams[]
Parameters
| Name | Type | 
|---|---|
filter? | (v: string[]) => boolean | 
Returns
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:366
encodeToABI
▸ encodeToABI(filter?): string
ABI-encode the proofs and parameters for the conditional orders in the merkle tree.
Parameters
| Name | Type | Description | 
|---|---|---|
filter? | (v: string[]) => boolean | getProofs | 
Returns
string
ABI-encoded data for the ProofStruct.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:408
encodeToJSON
▸ encodeToJSON(filter?): string
JSON-encode the proofs and parameters for the conditional orders in the merkle tree.
Parameters
| Name | Type | Description | 
|---|---|---|
filter? | (v: string[]) => boolean | getProofs | 
Returns
string
The JSON-encoded data for storage off-chain.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:417
getById
▸ getById(id): ConditionalOrder<unknown, unknown>
Accessor for a given conditional order in the multiplexer.
Parameters
| Name | Type | Description | 
|---|---|---|
id | string | The id of the ConditionalOrder to retrieve. | 
Returns
ConditionalOrder<unknown, unknown>
A ConditionalOrder with the given id.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:210
getByIndex
▸ getByIndex(i): ConditionalOrder<unknown, unknown>
Accessor for a given conditional order in the multiplexer.
Parameters
| Name | Type | Description | 
|---|---|---|
i | number | The index of the ConditionalOrder to retrieve. | 
Returns
ConditionalOrder<unknown, unknown>
A ConditionalOrder at the given index.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:219
getOrGenerateTree
▸ getOrGenerateTree(): StandardMerkleTree<string[]>
Retrieve the merkle tree of orders, or generate it if it doesn't exist.
CAUTION: Developers of the SDK should prefer to use this method instead of generating the merkle tree themselves. This method makes use of caching to avoid generating the merkle tree needlessly.
Returns
StandardMerkleTree<string[]>
The merkle tree for the current set of conditional orders.
Throws
If the merkle tree cannot be generated.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:243
getProofs
▸ getProofs(filter?): ProofWithParams[]
Get the proofs with parameters for the conditional orders in the merkle tree.
Parameters
| Name | Type | Description | 
|---|---|---|
filter? | (v: string[]) => boolean | A function that takes a conditional order and returns a boolean indicating whether the order should be included in the proof. | 
Returns
An array of proofs and their order's parameters for the conditional orders in the merkle tree.
Defined in
external/cow-sdk/src/composable/Multiplexer.ts:377