Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,25 @@
}
}
}
{
"name": "linea",
"rpc": "https://rpc.linea.build",
"deploymentBlock": 25028604,
"filterPolicy": {
"defaultAction": "ACCEPT",
"conditionalOrderIds": {
"0x5b3cdb6ffa3c95507cbfc459162609007865c2e87340312d3cd469c4ffbfae81": "DROP"
},
"transactions": {
"0x33ef06af308d1e4f94dd61fa8df43fe52b67e8a485f4e4fff75235080e663bfa": "DROP"
},
"handlers": {
"0xd3338f21c89745e46af56aeaf553cf96ba9bc66f": "DROP"
},
"owners": {
"0xd3338f21c89745e46af56aeaf553cf96ba9bc66f": "DROP"
}
}
}
]
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@cowprotocol/watch-tower",
"license": "GPL-3.0-or-later",
"version": "2.11.1",
"version": "2.13.0",
"description": "A standalone watch tower, keeping an eye on Composable Cows 👀🐮",
"author": {
"name": "Cow Protocol"
Expand Down Expand Up @@ -46,7 +46,9 @@
"dependencies": {
"@commander-js/extra-typings": "^11.0.0",
"@cowprotocol/contracts": "^1.4.0",
"@cowprotocol/cow-sdk": "6.2.0-RC.0",
"@cowprotocol/cow-sdk": "^7.1.0",
"@cowprotocol/sdk-composable": "^0.1.10",
"@cowprotocol/sdk-ethers-v5-adapter": "^0.2.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"chalk": "^4.1.2",
Expand Down
20 changes: 11 additions & 9 deletions src/domain/events/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
getAreConditionalOrderParamsEqual,
getLogger,
handleExecutionError,
metrics,
toConditionalOrderParams,
} from "../../utils";
ConditionalOrder,
ConditionalOrderParams,
} from "@cowprotocol/sdk-composable";
import { BytesLike, ethers } from "ethers";

import { ChainContext } from "../../services/chain";
import {
ComposableCoW,
ComposableCoW__factory,
Expand All @@ -17,9 +15,13 @@ import {
Proof,
Registry,
} from "../../types";
import { ConditionalOrder, ConditionalOrderParams } from "@cowprotocol/cow-sdk";

import { ChainContext } from "../../services/chain";
import {
getAreConditionalOrderParamsEqual,
getLogger,
handleExecutionError,
metrics,
toConditionalOrderParams,
} from "../../utils";
import { policy } from "../polling/filtering";

const composableCow = ComposableCoW__factory.createInterface();
Expand Down
3 changes: 2 additions & 1 deletion src/domain/polling/filtering/policy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConditionalOrderParams } from "@cowprotocol/cow-sdk";
import { ConditionalOrderParams } from "@cowprotocol/sdk-composable";

import { Config, FilterAction as FilterActionSchema } from "../../../types";

export enum FilterAction {
Expand Down
25 changes: 14 additions & 11 deletions src/domain/polling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ import {
OrderKind,
computeOrderUid,
} from "@cowprotocol/contracts";

import { ethers } from "ethers";
import { BytesLike } from "ethers/lib/utils";

import {
ConditionalOrder as ConditionalOrderSDK,
OrderBookApi,
OrderCreation,
OrderPostError,
SigningScheme,
SupportedChainId,
} from "@cowprotocol/cow-sdk";
import {
ConditionalOrder as ConditionalOrderSDK,
PollParams,
PollResult,
PollResultCode,
PollResultErrors,
PollResultSuccess,
SigningScheme,
SupportedChainId,
formatEpoch,
} from "@cowprotocol/cow-sdk";
} from "@cowprotocol/sdk-composable";
import { ethers } from "ethers";
import { BytesLike } from "ethers/lib/utils";

import { ChainContext } from "../../services";
import { ConditionalOrder, OrderStatus } from "../../types";

import {
LoggerWithMethods,
formatStatus,
Expand Down Expand Up @@ -410,9 +412,10 @@ async function processConditionalOrder(

const orderToSubmit: Order = {
...order,
kind: kindToString(order.kind.toString()),
sellTokenBalance: balanceToString(order.sellTokenBalance.toString()),
buyTokenBalance: balanceToString(order.buyTokenBalance.toString()),
appData: order.appData as string,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: do we have any guard for this? I've just remembered the case when appData was incorrect and our explorer page was broken

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope not. The type is defined in the SDK as Bytes, which is an alias for unknown.
Here I took the shortest path and used a casting.

kind: kindToString(order.kind as string),
sellTokenBalance: balanceToString(order.sellTokenBalance as string),
buyTokenBalance: balanceToString(order.buyTokenBalance as string),
validTo: Number(order.validTo),
};

Expand Down
4 changes: 2 additions & 2 deletions src/domain/polling/poll.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SupportedChainId } from "@cowprotocol/cow-sdk";
import {
ConditionalOrderFactory,
ConditionalOrderParams,
DEFAULT_CONDITIONAL_ORDER_REGISTRY,
PollParams,
PollResult,
SupportedChainId,
} from "@cowprotocol/cow-sdk";
} from "@cowprotocol/sdk-composable";
import { getLogger } from "../../utils/logging";

// Watch-tower will index every block, so we will by default the processing block and not the latest.
Expand Down
6 changes: 5 additions & 1 deletion src/services/chain.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {
ApiBaseUrls,
OrderBookApi,
setGlobalAdapter,
SupportedChainId,
} from "@cowprotocol/cow-sdk";
import { EthersV5Adapter } from "@cowprotocol/sdk-ethers-v5-adapter";
import { ethers, providers } from "ethers";
import { DBService } from ".";
import { processNewOrderEvent } from "../domain/events";
Expand All @@ -18,10 +20,10 @@ import {
RegistryBlock,
} from "../types";
import {
LoggerWithMethods,
composableCowContract,
getLogger,
isRunningInKubernetesPod,
LoggerWithMethods,
metrics,
} from "../utils";

Expand Down Expand Up @@ -152,6 +154,8 @@ export class ChainContext {
const provider = getProvider(rpc.toLowerCase());
const chainId = (await provider.getNetwork()).chainId;

setGlobalAdapter(new EthersV5Adapter({ provider: provider }));

const registry = await Registry.load(
storage,
chainId.toString(),
Expand Down
6 changes: 3 additions & 3 deletions src/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Slack = require("node-slack");
import { BytesLike } from "ethers";

import {
ConditionalOrder as ConditionalOrderSdk,
ConditionalOrderParams,
ConditionalOrder as ConditionalOrderSdk,
PollResult,
} from "@cowprotocol/cow-sdk";
} from "@cowprotocol/sdk-composable";
import { DBService } from "../services";
import * as metrics from "../utils/metrics";
import { getLogger } from "../utils/logging";
import * as metrics from "../utils/metrics";

// Standardise the storage key
const LAST_NOTIFIED_ERROR_STORAGE_KEY = "LAST_NOTIFIED_ERROR";
Expand Down
9 changes: 4 additions & 5 deletions src/utils/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { BigNumber, ethers } from "ethers";
import { ComposableCoW, ComposableCoW__factory } from "../types";
import {
COMPOSABLE_COW_CONTRACT_ADDRESS,
MAX_UINT32,
PollResultCode,
PollResultErrors,
SupportedChainId,
} from "@cowprotocol/cow-sdk";
import { getLogger } from "./logging";
import { PollResultCode, PollResultErrors } from "@cowprotocol/sdk-composable";
import { BigNumber, ethers } from "ethers";
import { metrics } from ".";
import { ComposableCoW, ComposableCoW__factory } from "../types";
import { getLogger } from "./logging";

// Define an enum for the custom error revert hints that can be returned by the ComposableCoW's interfaces.
export enum CustomErrorSelectors {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConditionalOrderParams } from "@cowprotocol/cow-sdk";
import { ConditionalOrderParams } from "@cowprotocol/sdk-composable";
import { IConditionalOrder, OrderStatus } from "../types";
export function formatStatus(status: OrderStatus) {
switch (status) {
Expand Down
Loading