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
2 changes: 1 addition & 1 deletion contracts/SpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ abstract contract SpokePool is SpokePoolInterface, Testable, Lockable, MultiCall
* @notice Returns chain ID for this network.
* @dev Some L2s like ZKSync don't support the CHAIN_ID opcode so we allow the implementer to override this.
*/
function chainId() public view override returns (uint256) {
function chainId() public view virtual override returns (uint256) {
return block.chainid;
}

Expand Down
11 changes: 11 additions & 0 deletions contracts/test/MockSpokePool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import "../SpokePoolInterface.sol";
* @notice Implements abstract contract for testing.
*/
contract MockSpokePool is SpokePoolInterface, SpokePool {
uint256 chainId_;

constructor(
address _crossDomainAdmin,
address _hubPool,
Expand All @@ -19,4 +21,13 @@ contract MockSpokePool is SpokePoolInterface, SpokePool {
function _bridgeTokensToHubPool(RelayerRefundLeaf memory relayerRefundLeaf) internal override {}

function _requireAdminSender() internal override {}

function chainId() public view override(SpokePool, SpokePoolInterface) returns (uint256) {
Copy link
Member

Choose a reason for hiding this comment

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

nit you can remove the override of the SpokePoolInterface if you remove this from the contract. I don't think the other SpokePools extend SpokePoolInterface anyways

// If chainId_ is set then return it, else do nothing and return the parent chainId().
return chainId_ == 0 ? super.chainId() : chainId_;
}

function setChainId(uint256 _chainId) public {
chainId_ = _chainId;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@across-protocol/contracts-v2",
"version": "0.0.17",
"version": "0.0.24",
"author": "UMA Team",
"license": "AGPL-3.0",
"repository": {
Expand Down
21 changes: 17 additions & 4 deletions test/fixtures/SpokePool.Fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import { getContractFactory, SignerWithAddress, Contract, hre, ethers, BigNumber
import * as consts from "../constants";

export const spokePoolFixture = hre.deployments.createFixture(async ({ ethers }) => {
return await deploySpokePool(ethers);
});

// Have a separate function that deploys the contract and returns the contract addresses. This is called by the fixture
// to have standard fixture features. It is also exported as a function to enable non-snapshoted deployments.
export async function deploySpokePool(ethers: any): Promise<{
timer: Contract;
weth: Contract;
erc20: Contract;
spokePool: Contract;
unwhitelistedErc20: Contract;
destErc20: Contract;
}> {
const [deployerWallet, crossChainAdmin, hubPool] = await ethers.getSigners();
// Useful contracts.
const timer = await (await getContractFactory("Timer", deployerWallet)).deploy();
Expand All @@ -27,7 +40,7 @@ export const spokePoolFixture = hre.deployments.createFixture(async ({ ethers })
).deploy(crossChainAdmin.address, hubPool.address, weth.address, timer.address);

return { timer, weth, erc20, spokePool, unwhitelistedErc20, destErc20 };
});
}

export interface DepositRoute {
originToken: string;
Expand Down Expand Up @@ -65,9 +78,9 @@ export async function deposit(
await spokePool.getCurrentTime()
)
);
const [events, networkInfo] = await Promise.all([
const [events, originChainId] = await Promise.all([
spokePool.queryFilter(spokePool.filters.FundsDeposited()),
spokePool.provider.getNetwork(),
spokePool.chainId(),
]);
const lastEvent = events[events.length - 1];
if (lastEvent.args)
Expand All @@ -80,7 +93,7 @@ export async function deposit(
originToken: lastEvent.args.originToken,
recipient: lastEvent.args.recipient,
depositor: lastEvent.args.depositor,
originChainId: networkInfo.chainId,
originChainId: Number(originChainId),
};
return null;
}
Expand Down