From 26c1b27e06c009d25f7fcbad34c38df2a62a504b Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Fri, 12 Jan 2024 12:44:44 +0100 Subject: [PATCH] chore: Temporarily import select v3 typechain defs For preparing v3 SpokePoolClient functionality in advance of bumping contracts-v2. --- src/interfaces/SpokePool.ts | 4 +- src/typechain.ts | 166 +++++++++++++++++++++++++++++++++++- 2 files changed, 167 insertions(+), 3 deletions(-) diff --git a/src/interfaces/SpokePool.ts b/src/interfaces/SpokePool.ts index 380c4f4fb..d36510da9 100644 --- a/src/interfaces/SpokePool.ts +++ b/src/interfaces/SpokePool.ts @@ -1,9 +1,9 @@ import { BigNumber } from "ethers"; import { SortableEvent } from "./Common"; -import { FundsDepositedEvent } from "../typechain"; +import { FundsDepositedEvent, V3FundsDepositedEvent } from "../typechain"; import { SpokePoolClient } from "../clients"; -export type { FundsDepositedEvent } from "../typechain"; +export type { FundsDepositedEvent, V3FundsDepositedEvent }; export interface Deposit { depositId: number; diff --git a/src/typechain.ts b/src/typechain.ts index 8702e6e8d..acfdc47f3 100644 --- a/src/typechain.ts +++ b/src/typechain.ts @@ -3,6 +3,10 @@ * Currently, the packages `@across-protocol/contracts-v2` and `@across-protocol/across-token` are not optimized for tree-shaking * and contain modules that are not compatible in a browser environment. This is a temporary solution until we can fix the issue upstream. */ +import { BigNumber, BigNumberish, BytesLike } from "ethers"; +import type { TypedEvent, TypedEventFilter } from "@across-protocol/contracts-v2/dist/typechain/common"; + +export type { TypedEvent, TypedEventFilter }; export { AcrossMerkleDistributor__factory } from "@across-protocol/contracts-v2/dist/typechain/factories/contracts/merkle-distributor/AcrossMerkleDistributor__factory"; export { AcrossConfigStore__factory } from "@across-protocol/contracts-v2/dist/typechain/factories/contracts/AcrossConfigStore__factory"; export { HubPool__factory } from "@across-protocol/contracts-v2/dist/typechain/factories/contracts/HubPool__factory"; @@ -29,7 +33,6 @@ export type { FilledRelayEvent, RequestedSpeedUpDepositEvent, } from "@across-protocol/contracts-v2/dist/typechain/contracts/SpokePool.sol/SpokePool"; -export type { TypedEvent, TypedEventFilter } from "@across-protocol/contracts-v2/dist/typechain/common"; export type { AcceleratingDistributor, @@ -40,3 +43,164 @@ export type { MerkleDistributor, MerkleDistributorInterface, } from "@across-protocol/across-token/dist/typechain/MerkleDistributor"; + +export interface V3FundsDepositedEventObject { + inputToken: string; + outputToken: string; + inputAmount: BigNumber; + outputAmount: BigNumber; + destinationChainId: BigNumber; + depositId: number; + quoteTimestamp: number; + fillDeadline: number; + exclusivityDeadline: number; + depositor: string; + recipient: string; + relayer: string; + message: string; +} +export declare type V3FundsDepositedEvent = TypedEvent< + [string, string, BigNumber, BigNumber, BigNumber, number, number, number, number, string, string, string, string], + V3FundsDepositedEventObject +>; + +export interface FilledV3RelayEventObject { + inputToken: string; + outputToken: string; + inputAmount: BigNumber; + outputAmount: BigNumber; + repaymentChainId: BigNumber; + originChainId: BigNumber; + depositId: number; + fillDeadline: number; + exclusivityDeadline: number; + exclusiveRelayer: string; + relayer: string; + depositor: string; + recipient: string; + message: string; + relayExecutionInfo: V3SpokePoolInterface.V3RelayExecutionEventInfoStructOutput; +} + +export declare type FilledV3RelayEvent = TypedEvent< + [ + string, + string, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + number, + number, + number, + string, + string, + string, + string, + string, + V3SpokePoolInterface.V3RelayExecutionEventInfoStructOutput, + ], + FilledV3RelayEventObject +>; + +/** + * Temporarily provide local definitions for the upcoming v3 data types. + * This defers the need to bump contracts-v2, which would otherwise be + * incompatible with the production code in relayer-v2. These defintions + * must be removed when contracts-v2 is finally bumped. + */ +// eslint-disable-next-line @typescript-eslint/no-namespace +export declare namespace V3SpokePoolInterface { + type V3RelayExecutionEventInfoStruct = { + updatedRecipient: string; + updatedMessage: BytesLike; + updatedOutputAmount: BigNumberish; + fillType: BigNumberish; + }; + type V3RelayExecutionEventInfoStructOutput = [string, string, BigNumber, number] & { + updatedRecipient: string; + updatedMessage: string; + updatedOutputAmount: BigNumber; + fillType: number; + }; + type V3RelayerRefundLeafStruct = { + amountToReturn: BigNumberish; + chainId: BigNumberish; + refundAmounts: BigNumberish[]; + leafId: BigNumberish; + l2TokenAddress: string; + refundAddresses: string[]; + fillsRefundedRoot: BytesLike; + fillsRefundedHash: string; + }; + type V3RelayerRefundLeafStructOutput = [ + BigNumber, + BigNumber, + BigNumber[], + number, + string, + string[], + string, + string, + ] & { + amountToReturn: BigNumber; + chainId: BigNumber; + refundAmounts: BigNumber[]; + leafId: number; + l2TokenAddress: string; + refundAddresses: string[]; + fillsRefundedRoot: string; + fillsRefundedHash: string; + }; + type V3RelayDataStruct = { + depositor: string; + recipient: string; + exclusiveRelayer: string; + inputToken: string; + outputToken: string; + inputAmount: BigNumberish; + outputAmount: BigNumberish; + originChainId: BigNumberish; + depositId: BigNumberish; + fillDeadline: BigNumberish; + exclusivityDeadline: BigNumberish; + message: BytesLike; + }; + type V3RelayDataStructOutput = [ + string, + string, + string, + string, + string, + BigNumber, + BigNumber, + BigNumber, + number, + number, + number, + string, + ] & { + depositor: string; + recipient: string; + exclusiveRelayer: string; + inputToken: string; + outputToken: string; + inputAmount: BigNumber; + outputAmount: BigNumber; + originChainId: BigNumber; + depositId: number; + fillDeadline: number; + exclusivityDeadline: number; + message: string; + }; + type V3SlowFillStruct = { + relayData: V3SpokePoolInterface.V3RelayDataStruct; + chainId: BigNumberish; + updatedOutputAmount: BigNumberish; + }; + type V3SlowFillStructOutput = [V3SpokePoolInterface.V3RelayDataStructOutput, BigNumber, BigNumber] & { + relayData: V3SpokePoolInterface.V3RelayDataStructOutput; + chainId: BigNumber; + updatedOutputAmount: BigNumber; + }; +}