Skip to content

Commit

Permalink
Declare the context
Browse files Browse the repository at this point in the history
  • Loading branch information
anxolin committed Aug 30, 2023
1 parent 665959f commit fcc1ea7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/composable/ConditionalOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export abstract class ConditionalOrder<D, S> {
this.hasOffChainInput = hasOffChainInput
}

// TODO: https://github.com/cowprotocol/cow-sdk/issues/155
abstract get isSingleOrder(): boolean

/**
Expand Down Expand Up @@ -155,6 +156,15 @@ export abstract class ConditionalOrder<D, S> {
return utils.keccak256(this.serialize())
}

/**
* The context key of the order (bytes32(0) if a merkle tree is used, otherwise H(params)) with which to lookup the cabinet
*
* The context, relates to the 'ctx' in the contract: https://github.com/cowprotocol/composable-cow/blob/c7fb85ab10c05e28a1632ba97a1749fb261fcdfb/src/interfaces/IConditionalOrder.sol#L38
*/
protected get ctx(): string {
return this.isSingleOrder ? this.id : constants.HashZero
}

/**
* Get the `leaf` of the conditional order. This is the data that is used to create the merkle tree.
*
Expand Down Expand Up @@ -304,10 +314,8 @@ export abstract class ConditionalOrder<D, S> {
public cabinet(params: OwnerContext): Promise<string> {
const { chainId, owner, provider } = params

const slotId = this.isSingleOrder ? this.id : constants.HashZero

const composableCow = getComposableCow(chainId, provider)
return composableCow.callStatic.cabinet(owner, slotId)
return composableCow.callStatic.cabinet(owner, this.ctx)
}

/**
Expand Down

0 comments on commit fcc1ea7

Please sign in to comment.