Skip to content

Commit 9734af5

Browse files
committed
Fix
1 parent c8e4ea2 commit 9734af5

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

contracts/ZkSync_SpokePool.sol

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "./SpokePool.sol";
99
// https://github.com/matter-labs/era-contracts/blob/48e189814aabb43964ed29817a7f05aa36f09fd6/l1-contracts/contracts/bridge/asset-router/L2AssetRouter.sol#L321
1010
interface IL2AssetRouter {
1111
function withdraw(bytes32 _assetId, bytes memory _assetData) external returns (bytes32);
12+
function l1TokenAddress(address _l2TokenAddress) external view returns (address);
1213
}
1314

1415
// https://github.com/matter-labs/era-contracts/blob/6391c0d7bf6184d7f6718060e3991ba6f0efe4a7/zksync/contracts/bridge/L2ERC20Bridge.sol#L104
@@ -49,14 +50,14 @@ contract ZkSync_SpokePool is SpokePool, CircleCCTPAdapter {
4950

5051
/// Contract used to withdraw ERC20's to L1.
5152
/// Source: https://github.com/matter-labs/era-contracts/blob/48e189814aabb43964ed29817a7f05aa36f09fd6/l1-contracts/contracts/common/l2-helpers/L2ContractAddresses.sol#L68
52-
address constant L2_ASSET_ROUTER_ADDR = address(USER_CONTRACTS_OFFSET + 0x03);
53+
address public constant L2_ASSET_ROUTER_ADDR = address(USER_CONTRACTS_OFFSET + 0x03);
5354
IL2AssetRouter public constant l2AssetRouter = IL2AssetRouter(L2_ASSET_ROUTER_ADDR);
5455

5556
/// @dev An l2 system contract address, used in the assetId calculation for native assets.
5657
/// This is needed for automatic bridging, i.e. without deploying the AssetHandler contract,
5758
/// if the assetId can be calculated with this address then it is in fact an NTV asset
5859
/// Source: https://github.com/matter-labs/era-contracts/blob/48e189814aabb43964ed29817a7f05aa36f09fd6/l1-contracts/contracts/common/l2-helpers/L2ContractAddresses.sol#L70C1-L73C85
59-
address constant L2_NATIVE_TOKEN_VAULT_ADDR = address(USER_CONTRACTS_OFFSET + 0x04);
60+
address public constant L2_NATIVE_TOKEN_VAULT_ADDR = address(USER_CONTRACTS_OFFSET + 0x04);
6061

6162
/// Used to compute asset ID needed to withdraw tokens.
6263
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
@@ -191,8 +192,9 @@ contract ZkSync_SpokePool is SpokePool, CircleCCTPAdapter {
191192
}
192193

193194
// Implementation from https://github.com/matter-labs/era-contracts/blob/48e189814aabb43964ed29817a7f05aa36f09fd6/l1-contracts/contracts/common/libraries/DataEncoding.sol#L117C14-L117C62
194-
function _getAssetId(address _tokenAddress) internal view returns (bytes32) {
195-
return keccak256(abi.encode(l1ChainId, L2_NATIVE_TOKEN_VAULT_ADDR, _tokenAddress));
195+
function _getAssetId(address _l2TokenAddress) internal view returns (bytes32) {
196+
address l1TokenAddress = l2AssetRouter.l1TokenAddress(_l2TokenAddress);
197+
return keccak256(abi.encode(l1ChainId, L2_NATIVE_TOKEN_VAULT_ADDR, l1TokenAddress));
196198
}
197199

198200
// Implementation from https://github.com/matter-labs/era-contracts/blob/48e189814aabb43964ed29817a7f05aa36f09fd6/l1-contracts/contracts/common/libraries/DataEncoding.sol#L24C1-L30C6

test/evm/hardhat/chain-specific-spokepools/ZkSync_SpokePool.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ const abiData = {
3737
stateMutability: "nonpayable",
3838
type: "function",
3939
},
40+
{
41+
inputs: [{ internalType: "address", name: "_l2TokenAddress", type: "address" }],
42+
name: "l1TokenAddress",
43+
outputs: [{ internalType: "address", name: "", type: "address" }],
44+
stateMutability: "view",
45+
type: "function",
46+
},
4047
],
4148
},
4249
erc20DefaultBridge: {

0 commit comments

Comments
 (0)