Skip to content

Commit

Permalink
Merge branch 'dev' into docs/automated-dispute
Browse files Browse the repository at this point in the history
  • Loading branch information
0xyaco authored Nov 22, 2024
2 parents 5a66e9c + f687dc5 commit cb6ebc8
Show file tree
Hide file tree
Showing 23 changed files with 962 additions and 2,101 deletions.
2 changes: 1 addition & 1 deletion apps/agent/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ BLOCK_NUMBER_BLOCKMETA_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNlIjoidH
EBO_AGENT_CONFIG_FILE_PATH="./config.example.yml"

# Discord webhook notifications
DISCORD_WEBHOOK=YOUR_DISCORD_WEBHOOK
DISCORD_WEBHOOK=YOUR_DISCORD_WEBHOOK
2 changes: 2 additions & 0 deletions apps/agent/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ protocolProvider:
eboRequestCreator: "0x1234567890123456789012345678901234567890" # EBO Request Creator contract
bondEscalationModule: "0x1234567890123456789012345678901234567890" # Bond Escalation Module contract
horizonAccountingExtension: "0x1234567890123456789012345678901234567890" # Accounting extension contract
accessControl:
serviceProviderAddress: "0x1234567890123456789012345678901234567890" # Service Provider Address

blockNumberService:
blockmetaConfig:
Expand Down
11 changes: 11 additions & 0 deletions apps/agent/src/config/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const envSchema = z.object({
});

const addressSchema = z.string().refine((address) => isAddress(address));

const rpcConfigSchema = z.object({
chainId: z
.string()
Expand All @@ -43,6 +44,15 @@ const rpcConfigSchema = z.object({
retryInterval: z.number().int().positive(),
});

export const accessControlSchema = z.object({
serviceProviderAddress: z
.string()
.refine((val) => isAddress(val), {
message: "serviceProviderAddress must be a valid blockchain address",
})
.optional(),
});

const protocolProviderConfigSchema = z.object({
rpcsConfig: z.object({
l1: rpcConfigSchema,
Expand All @@ -55,6 +65,7 @@ const protocolProviderConfigSchema = z.object({
bondEscalationModule: addressSchema,
horizonAccountingExtension: addressSchema,
}),
accessControl: accessControlSchema.optional(),
});

const blockNumberServiceSchema = z.object({
Expand Down
1 change: 1 addition & 0 deletions apps/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const main = async (): Promise<void> => {
config.protocolProvider.rpcsConfig,
config.protocolProvider.contracts,
config.protocolProvider.privateKey,
config.protocolProvider.accessControl?.serviceProviderAddress,
logger,
blockNumberService,
);
Expand Down
16 changes: 14 additions & 2 deletions apps/scripts/utilities/approveAccountingModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ProtocolProvider } from "@ebo-agent/automated-dispute/src/index.js";
import { mockLogger } from "@ebo-agent/automated-dispute/tests/mocks/logger.mocks.js";
import { Caip2ChainId } from "@ebo-agent/shared";
import * as dotenv from "dotenv";
import { Address, Hex, isHex } from "viem";
import { Address, Hex, isAddress, isHex } from "viem";
import { z } from "zod";

dotenv.config();
Expand Down Expand Up @@ -70,6 +70,12 @@ const envSchema = z.object({
CONTRACTS_ADDRESSES: stringToJSONSchema.pipe(contractsAddressesSchema),
BONDED_RESPONSE_MODULE_ADDRESS: z.string().min(1, "BONDED_RESPONSE_MODULE_ADDRESS is required"),
BOND_ESCALATION_MODULE_ADDRESS: z.string().min(1, "BOND_ESCALATION_MODULE_ADDRESS is required"),
SERVICE_PROVIDER_ADDRESS: z
.string()
.refine((val) => isAddress(val), {
message: "SERVICE_PROVIDER_ADDRESS must be a valid blockchain address",
})
.optional(),
});

const envResult = envSchema.safeParse(process.env);
Expand Down Expand Up @@ -103,7 +109,13 @@ const rpcConfig = {

const contracts = env.CONTRACTS_ADDRESSES;

const provider = new ProtocolProvider(rpcConfig, contracts, env.PRIVATE_KEY as Hex, mockLogger());
const provider = new ProtocolProvider(
rpcConfig,
contracts,
env.PRIVATE_KEY as Hex,
env.SERVICE_PROVIDER_ADDRESS,
mockLogger(),
);

/**
* Approves the necessary modules by calling approveModule on ProtocolProvider.
Expand Down
Loading

0 comments on commit cb6ebc8

Please sign in to comment.