Skip to content

Commit

Permalink
Merge pull request #26 from gelatodigital/feat/abstract
Browse files Browse the repository at this point in the history
Add support for Abstract chain and a new set of addresses on zkSync s…
  • Loading branch information
KostasCherv authored Jan 31, 2025
2 parents f15f6ec + 39e5ab3 commit f449a58
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
10 changes: 7 additions & 3 deletions contracts/base/GelatoRelayBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
import {
GELATO_RELAY_V1,
GELATO_RELAY_V2,
GELATO_RELAY_ZKSYNC
GELATO_RELAY_ZKSYNC_V1,
GELATO_RELAY_ZKSYNC_V2
} from "../constants/GelatoRelay.sol";

abstract contract GelatoRelayBase is GelatoRelayContractsUtils {
Expand All @@ -17,8 +18,11 @@ abstract contract GelatoRelayBase is GelatoRelayContractsUtils {
}

function _isGelatoRelay(address _forwarder) internal view returns (bool) {
if (_isZkSyncChainId) {
return _forwarder == GELATO_RELAY_ZKSYNC;
if (_isV1ZkSyncChainId) {
return _forwarder == GELATO_RELAY_ZKSYNC_V1;
}
if (_isV2ZkSyncChainId) {
return _forwarder == GELATO_RELAY_ZKSYNC_V2;
}
if (_isV1ChainId) {
return _forwarder == GELATO_RELAY_V1;
Expand Down
16 changes: 11 additions & 5 deletions contracts/base/GelatoRelayERC2771Base.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
GELATO_RELAY_CONCURRENT_ERC2771_V1,
GELATO_RELAY_ERC2771_V2,
GELATO_RELAY_CONCURRENT_ERC2771_V2,
GELATO_RELAY_ERC2771_ZKSYNC,
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC
GELATO_RELAY_ERC2771_ZKSYNC_V1,
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_V1,
GELATO_RELAY_ERC2771_ZKSYNC_V2,
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_V2
} from "../constants/GelatoRelay.sol";

abstract contract GelatoRelayERC2771Base is GelatoRelayContractsUtils {
Expand All @@ -25,9 +27,13 @@ abstract contract GelatoRelayERC2771Base is GelatoRelayContractsUtils {
returns (bool)
{
// Use another address on zkSync
if (_isZkSyncChainId) {
return (_forwarder == GELATO_RELAY_ERC2771_ZKSYNC ||
_forwarder == GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC);
if (_isV1ZkSyncChainId) {
return (_forwarder == GELATO_RELAY_ERC2771_ZKSYNC_V1 ||
_forwarder == GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_V1);
}
if (_isV2ZkSyncChainId) {
return (_forwarder == GELATO_RELAY_ERC2771_ZKSYNC_V2 ||
_forwarder == GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_V2);
}
if (_isV1ChainId) {
return (_forwarder == GELATO_RELAY_ERC2771_V1 ||
Expand Down
11 changes: 8 additions & 3 deletions contracts/constants/GelatoRelay.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ address constant GELATO_RELAY_V2 = 0xcd565435e0d2109feFde337a66491541Df0D1420;
address constant GELATO_RELAY_ERC2771_V2 = 0x8aCE64CEA52b409F930f60B516F65197faD4B056;
address constant GELATO_RELAY_CONCURRENT_ERC2771_V2 = 0xc7739c195618D314C08E8626C98f8573E4E43634;

address constant GELATO_RELAY_ZKSYNC = 0xB16a1DbE755f992636705fDbb3A8678a657EB3ea;
address constant GELATO_RELAY_ERC2771_ZKSYNC = 0x22DCC39b2AC376862183dd35A1664798dafC7Da6;
address constant GELATO_RELAY_ZKSYNC_V1 = 0xB16a1DbE755f992636705fDbb3A8678a657EB3ea;
address constant GELATO_RELAY_ERC2771_ZKSYNC_V1 = 0x22DCC39b2AC376862183dd35A1664798dafC7Da6;
// solhint-disable-next-line max-line-length
address constant GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC = 0xBa4082F4961c8Fb76231995C967CD9aa40f321b5;
address constant GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_V1 = 0xBa4082F4961c8Fb76231995C967CD9aa40f321b5;

address constant GELATO_RELAY_ZKSYNC_V2 = 0x42120A1417a091a52A8d4590E28fc6C0F61E5632;
address constant GELATO_RELAY_ERC2771_ZKSYNC_V2 = 0xACeD988c5B5Fe3f11848c728D9a5f66Cf34c9e73;
// solhint-disable-next-line max-line-length
address constant GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_V2 = 0xbbCe89ACdD86D0130BDc3f1fe37C3aEDd79fc1F4;
15 changes: 12 additions & 3 deletions contracts/utils/GelatoRelayContractsUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ pragma solidity ^0.8.1;

abstract contract GelatoRelayContractsUtils {
bool internal immutable _isV1ChainId;
bool internal immutable _isZkSyncChainId;
bool internal immutable _isV1ZkSyncChainId;
bool internal immutable _isV2ZkSyncChainId;

constructor() {
_isV1ChainId = __isV1ChainId(block.chainid);
_isZkSyncChainId = __isZkSyncChainId(block.chainid);
_isV1ZkSyncChainId = __isV1ZkSyncChainId(block.chainid);
_isV2ZkSyncChainId = __isV2ZkSyncChainId(block.chainid);
}

// solhint-disable-next-line function-max-lines
Expand Down Expand Up @@ -80,10 +82,17 @@ abstract contract GelatoRelayContractsUtils {
}
}

function __isZkSyncChainId(uint256 chainId) private pure returns (bool) {
function __isV1ZkSyncChainId(uint256 chainId) private pure returns (bool) {
if (chainId == 324 || chainId == 280) {
return true;
}
return false;
}

function __isV2ZkSyncChainId(uint256 chainId) private pure returns (bool) {
if (chainId == 11124 || chainId == 2741) {
return true;
}
return false;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gelatonetwork/relay-context",
"version": "4.0.0",
"version": "4.1.0",
"description": "Solidity and test helpers for implementing GelatoRelayContext",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down

0 comments on commit f449a58

Please sign in to comment.