Commit d46b6b5e authored by smartcontracts's avatar smartcontracts Committed by GitHub

Merge pull request #1896 from ethereum-optimism/sc/cc-messenger-test-scaffold

feat: add CrossChainMessenger test scaffold and CrossChainERC20Pair API
parents a2e67b48 a7b9f2e7
import { Overrides, Contract } from 'ethers'
import {
TransactionRequest,
TransactionResponse,
} from '@ethersproject/abstract-provider'
import { NumberLike, L1ToL2Overrides } from './types'
import { ICrossChainMessenger } from './cross-chain-messenger'
/**
* Represents an L1<>L2 ERC20 token pair.
*/
export interface ICrossChainERC20Pair {
/**
* Messenger that will be used to carry out cross-chain iteractions.
*/
messenger: ICrossChainMessenger
/**
* Ethers Contract object connected to the L1 token.
*/
l1Token: Contract
/**
* Ethers Contract object connected to the L2 token.
*/
l2Token: Contract
/**
* Deposits some tokens into the L2 chain.
*
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the deposit transaction.
*/
deposit(
amount: NumberLike,
overrides?: L1ToL2Overrides
): Promise<TransactionResponse>
/**
* Withdraws some tokens back to the L1 chain.
*
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the withdraw transaction.
*/
withdraw(
amount: NumberLike,
overrides?: Overrides
): Promise<TransactionResponse>
/**
* Object that holds the functions that generate transactions to be signed by the user.
* Follows the pattern used by ethers.js.
*/
populateTransaction: {
/**
* Generates a transaction for depositing some tokens into the L2 chain.
*
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
deposit(
amount: NumberLike,
overrides?: L1ToL2Overrides
): Promise<TransactionResponse>
/**
* Generates a transaction for withdrawing some tokens back to the L1 chain.
*
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdraw(
amount: NumberLike,
overrides?: Overrides
): Promise<TransactionRequest>
}
/**
* Object that holds the functions that estimates the gas required for a given transaction.
* Follows the pattern used by ethers.js.
*/
estimateGas: {
/**
* Estimates gas required to deposit some tokens into the L2 chain.
*
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
deposit(
amount: NumberLike,
overrides?: L1ToL2Overrides
): Promise<TransactionResponse>
/**
* Estimates gas required to withdraw some tokens back to the L1 chain.
*
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdraw(
amount: NumberLike,
overrides?: Overrides
): Promise<TransactionRequest>
}
}
...@@ -5,7 +5,6 @@ import { ...@@ -5,7 +5,6 @@ import {
} from '@ethersproject/abstract-provider' } from '@ethersproject/abstract-provider'
import { import {
MessageLike, MessageLike,
AddressLike,
NumberLike, NumberLike,
CrossChainMessageRequest, CrossChainMessageRequest,
L1ToL2Overrides, L1ToL2Overrides,
...@@ -67,20 +66,6 @@ export interface ICrossChainMessenger { ...@@ -67,20 +66,6 @@ export interface ICrossChainMessenger {
overrides?: Overrides overrides?: Overrides
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/**
* Deposits some tokens into the L2 chain.
*
* @param token Address of the token to deposit.
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the deposit transaction.
*/
depositTokens(
token: AddressLike,
amount: NumberLike,
overrides?: L1ToL2Overrides
): Promise<TransactionResponse>
/** /**
* Deposits some ETH into the L2 chain. * Deposits some ETH into the L2 chain.
* *
...@@ -93,20 +78,6 @@ export interface ICrossChainMessenger { ...@@ -93,20 +78,6 @@ export interface ICrossChainMessenger {
overrides?: L1ToL2Overrides overrides?: L1ToL2Overrides
): Promise<TransactionResponse> ): Promise<TransactionResponse>
/**
* Withdraws some tokens back to the L1 chain.
*
* @param token Address of the token to withdraw.
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction response for the withdraw transaction.
*/
withdrawTokens(
token: AddressLike,
amount: NumberLike,
overrides?: Overrides
): Promise<TransactionResponse>
/** /**
* Withdraws some ETH back to the L1 chain. * Withdraws some ETH back to the L1 chain.
* *
...@@ -166,20 +137,6 @@ export interface ICrossChainMessenger { ...@@ -166,20 +137,6 @@ export interface ICrossChainMessenger {
overrides?: Overrides overrides?: Overrides
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/**
* Generates a transaction for depositing some tokens into the L2 chain.
*
* @param token Address of the token to deposit.
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
depositTokens(
token: AddressLike,
amount: NumberLike,
overrides?: L1ToL2Overrides
): Promise<TransactionResponse>
/** /**
* Generates a transaction for depositing some ETH into the L2 chain. * Generates a transaction for depositing some ETH into the L2 chain.
* *
...@@ -192,20 +149,6 @@ export interface ICrossChainMessenger { ...@@ -192,20 +149,6 @@ export interface ICrossChainMessenger {
overrides?: L1ToL2Overrides overrides?: L1ToL2Overrides
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/**
* Generates a transaction for withdrawing some tokens back to the L1 chain.
*
* @param token Address of the token to withdraw.
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdrawTokens(
token: AddressLike,
amount: NumberLike,
overrides?: Overrides
): Promise<TransactionRequest>
/** /**
* Generates a transaction for withdrawing some ETH back to the L1 chain. * Generates a transaction for withdrawing some ETH back to the L1 chain.
* *
...@@ -262,20 +205,6 @@ export interface ICrossChainMessenger { ...@@ -262,20 +205,6 @@ export interface ICrossChainMessenger {
overrides?: Overrides overrides?: Overrides
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/**
* Estimates gas required to deposit some tokens into the L2 chain.
*
* @param token Address of the token to deposit.
* @param amount Amount of the token to deposit.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to deposit the tokens.
*/
depositTokens(
token: AddressLike,
amount: NumberLike,
overrides?: L1ToL2Overrides
): Promise<TransactionResponse>
/** /**
* Estimates gas required to deposit some ETH into the L2 chain. * Estimates gas required to deposit some ETH into the L2 chain.
* *
...@@ -288,20 +217,6 @@ export interface ICrossChainMessenger { ...@@ -288,20 +217,6 @@ export interface ICrossChainMessenger {
overrides?: L1ToL2Overrides overrides?: L1ToL2Overrides
): Promise<TransactionRequest> ): Promise<TransactionRequest>
/**
* Estimates gas required to withdraw some tokens back to the L1 chain.
*
* @param token Address of the token to withdraw.
* @param amount Amount of the token to withdraw.
* @param overrides Optional transaction overrides.
* @returns Transaction that can be signed and executed to withdraw the tokens.
*/
withdrawTokens(
token: AddressLike,
amount: NumberLike,
overrides?: Overrides
): Promise<TransactionRequest>
/** /**
* Estimates gas required to withdraw some ETH back to the L1 chain. * Estimates gas required to withdraw some ETH back to the L1 chain.
* *
......
export * from './cross-chain-erc20-pair'
export * from './cross-chain-messenger' export * from './cross-chain-messenger'
export * from './cross-chain-provider' export * from './cross-chain-provider'
export * from './l2-provider' export * from './l2-provider'
......
/* eslint-disable @typescript-eslint/no-empty-function */
import './setup'
describe('CrossChainMessenger', () => {
describe('sendMessage', () => {
describe('when no l2GasLimit is provided', () => {
it('should send a message with an estimated l2GasLimit', () => {})
})
describe('when an l2GasLimit is provided', () => {
it('should send a message with the provided l2GasLimit', () => {})
})
})
describe('resendMessage', () => {
describe('when the message being resent exists', () => {
it('should resend the message with the new gas limit', () => {})
})
describe('when the message being resent does not exist', () => {
it('should throw an error', () => {})
})
})
describe('finalizeMessage', () => {
describe('when the message being finalized exists', () => {
describe('when the message is ready to be finalized', () => {
it('should finalize the message', () => {})
})
describe('when the message is not ready to be finalized', () => {
it('should throw an error', () => {})
})
// TODO: is this the behavior we want?
describe('when the message has already been finalized', () => {
it('should throw an error', () => {})
})
})
describe('when the message being finalized does not exist', () => {
it('should throw an error', () => {})
})
})
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment