Skip to content

Commit

Permalink
Merge pull request #52 from gelatodigital/chore/add-abstract
Browse files Browse the repository at this point in the history
chore: add abstract
  • Loading branch information
KostasCherv authored Feb 3, 2025
2 parents 8b0dff0 + dc9416c commit 898449b
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 18 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gelatonetwork/relay-sdk",
"version": "5.5.6",
"version": "5.6.0",
"description": "SDK to integrate with Gelato Relay",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -40,10 +40,10 @@
"typescript": "5.0.4"
},
"dependencies": {
"axios": "0.27.2",
"axios": "0.29.0",
"ethers": "6.7.0",
"isomorphic-ws": "^5.0.0",
"ws": "^8.5.0"
"ws": "^8.18.0"
},
"lint-staged": {
"*.{js,json,md,ts}": "yarn format",
Expand Down
10 changes: 10 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export const GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS =
export const GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS =
"0x97015cD4C3d456997DD1C40e2a18c79108FCc412";

export const GELATO_RELAY_ERC2771_ABSTRACT_ADDRESS =
"0xACeD988c5B5Fe3f11848c728D9a5f66Cf34c9e73";
export const GELATO_RELAY_1BALANCE_ERC2771_ABSTRACT_ADDRESS =
"0xD4bb348BD06877F52b0033f444048459108Fd9A0";

export const GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS =
"0x8598806401A63Ddf52473F1B3C55bC9E33e2d73b";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS =
Expand All @@ -28,3 +33,8 @@ export const GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS =
"0xBa4082F4961c8Fb76231995C967CD9aa40f321b5";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS =
"0xB8828e4c662D1a7e4f3d1f622EfAE6B63D852ED8";

export const GELATO_RELAY_CONCURRENT_ERC2771_ABSTRACT_ADDRESS =
"0xbbCe89ACdD86D0130BDc3f1fe37C3aEDd79fc1F4";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ABSTRACT_ADDRESS =
"0x0BdB9f40DCD2a56b2c5233D9d8d6FD49b5eeadA7";
16 changes: 16 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import {
GELATO_RELAY_URL,
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ABSTRACT_ADDRESS,
GELATO_RELAY_1BALANCE_ERC2771_ABSTRACT_ADDRESS,
GELATO_RELAY_CONCURRENT_ERC2771_ABSTRACT_ADDRESS,
GELATO_RELAY_ERC2771_ABSTRACT_ADDRESS,
} from "./constants";
import { WebsocketHandler } from "./utils/index.js";

Expand Down Expand Up @@ -80,9 +84,15 @@ export class GelatoRelay {
relayERC2771zkSync:
config?.contract?.relayERC2771zkSync ??
GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS,
relayERC2771Abstract:
config?.contract?.relayERC2771Abstract ??
GELATO_RELAY_ERC2771_ABSTRACT_ADDRESS,
relay1BalanceERC2771zkSync:
config?.contract?.relay1BalanceERC2771zkSync ??
GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS,
relay1BalanceERC2771Abstract:
config?.contract?.relay1BalanceERC2771Abstract ??
GELATO_RELAY_1BALANCE_ERC2771_ABSTRACT_ADDRESS,
relayConcurrentERC2771:
config?.contract?.relayConcurrentERC2771 ??
GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS,
Expand All @@ -92,9 +102,15 @@ export class GelatoRelay {
relayConcurrentERC2771zkSync:
config?.contract?.relayConcurrentERC2771zkSync ??
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
relayConcurrentERC2771Abstract:
config?.contract?.relayConcurrentERC2771Abstract ??
GELATO_RELAY_CONCURRENT_ERC2771_ABSTRACT_ADDRESS,
relay1BalanceConcurrentERC2771zkSync:
config?.contract?.relay1BalanceConcurrentERC2771zkSync ??
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
relay1BalanceConcurrentERC2771Abstract:
config?.contract?.relay1BalanceConcurrentERC2771Abstract ??
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ABSTRACT_ADDRESS,
},
};
};
Expand Down
4 changes: 4 additions & 0 deletions src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ export type Config = {
relayERC2771: string;
relay1BalanceERC2771: string;
relayERC2771zkSync: string;
relayERC2771Abstract: string;
relay1BalanceERC2771zkSync: string;
relay1BalanceERC2771Abstract: string;
relayConcurrentERC2771: string;
relay1BalanceConcurrentERC2771: string;
relayConcurrentERC2771zkSync: string;
relayConcurrentERC2771Abstract: string;
relay1BalanceConcurrentERC2771zkSync: string;
relay1BalanceConcurrentERC2771Abstract: string;
};
};

Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from "./post";
export * from "./isSigner";
export * from "./relayAddress";
export * from "./isZkSync";
export * from "./isAbstract";
export * from "./getProviderChainId";
export * from "./axios";
export * from "./isConcurrentStruct";
Expand Down
3 changes: 3 additions & 0 deletions src/utils/isAbstract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const isAbstract = (chainId: bigint): boolean => {
return chainId === BigInt(2741);
};
9 changes: 9 additions & 0 deletions src/utils/relayAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ERC2771Type } from "../lib/erc2771/types";
import { Config } from "../lib/types";

import { isZkSync } from "./isZkSync";
import { isAbstract } from "./isAbstract";

export const getGelatoRelayERC2771Address = (
payload: {
Expand All @@ -17,18 +18,26 @@ export const getGelatoRelayERC2771Address = (
case ERC2771Type.CallWithSyncFee:
return isZkSync(chainId)
? getAddress(config.contract.relayERC2771zkSync)
: isAbstract(chainId)
? getAddress(config.contract.relayERC2771Abstract)
: getAddress(config.contract.relayERC2771);
case ERC2771Type.SponsoredCall:
return isZkSync(chainId)
? getAddress(config.contract.relay1BalanceERC2771zkSync)
: isAbstract(chainId)
? getAddress(config.contract.relay1BalanceERC2771Abstract)
: getAddress(config.contract.relay1BalanceERC2771);
case ERC2771Type.ConcurrentCallWithSyncFee:
return isZkSync(chainId)
? getAddress(config.contract.relayConcurrentERC2771zkSync)
: isAbstract(chainId)
? getAddress(config.contract.relayConcurrentERC2771Abstract)
: getAddress(config.contract.relayConcurrentERC2771);
case ERC2771Type.ConcurrentSponsoredCall:
return isZkSync(chainId)
? getAddress(config.contract.relay1BalanceConcurrentERC2771zkSync)
: isAbstract(chainId)
? getAddress(config.contract.relay1BalanceConcurrentERC2771Abstract)
: getAddress(config.contract.relay1BalanceConcurrentERC2771);
default:
// eslint-disable-next-line no-case-declarations
Expand Down
38 changes: 23 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ __metadata:
"@types/node": "npm:16.18.25"
"@typescript-eslint/eslint-plugin": "npm:^5.59.1"
"@typescript-eslint/parser": "npm:^5.59.1"
axios: "npm:0.27.2"
axios: "npm:0.29.0"
dotenv: "npm:^16.0.3"
eslint: "npm:^8.39.0"
eslint-config-prettier: "npm:^8.8.0"
Expand All @@ -510,7 +510,7 @@ __metadata:
minimize-js: "npm:^1.3.1"
prettier: "npm:^2.8.8"
typescript: "npm:5.0.4"
ws: "npm:^8.5.0"
ws: "npm:^8.18.0"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -1085,13 +1085,14 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:0.27.2":
version: 0.27.2
resolution: "axios@npm:0.27.2"
"axios@npm:0.29.0":
version: 0.29.0
resolution: "axios@npm:0.29.0"
dependencies:
follow-redirects: "npm:^1.14.9"
follow-redirects: "npm:^1.15.4"
form-data: "npm:^4.0.0"
checksum: 10c0/76d673d2a90629944b44d6f345f01e58e9174690f635115d5ffd4aca495d99bcd8f95c590d5ccb473513f5ebc1d1a6e8934580d0c57cdd0498c3a101313ef771
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/53763099fe46d8a43700401e18db112d53f1fa9fe6beb6909742644e388d31928fba920c9a218334684b1a4b587112c7819671e372395bd66120adae8c014736
languageName: node
linkType: hard

Expand Down Expand Up @@ -2336,13 +2337,13 @@ __metadata:
languageName: node
linkType: hard

"follow-redirects@npm:^1.14.9":
version: 1.15.2
resolution: "follow-redirects@npm:1.15.2"
"follow-redirects@npm:^1.15.4":
version: 1.15.9
resolution: "follow-redirects@npm:1.15.9"
peerDependenciesMeta:
debug:
optional: true
checksum: 10c0/da5932b70e63944d38eecaa16954bac4347036f08303c913d166eda74809d8797d38386e3a0eb1d2fe37d2aaff2764cce8e9dbd99459d860cf2cdfa237923b5f
checksum: 10c0/5829165bd112c3c0e82be6c15b1a58fa9dcfaede3b3c54697a82fe4a62dd5ae5e8222956b448d2f98e331525f05d00404aba7d696de9e761ef6e42fdc780244f
languageName: node
linkType: hard

Expand Down Expand Up @@ -3991,6 +3992,13 @@ __metadata:
languageName: node
linkType: hard

"proxy-from-env@npm:^1.1.0":
version: 1.1.0
resolution: "proxy-from-env@npm:1.1.0"
checksum: 10c0/fe7dd8b1bdbbbea18d1459107729c3e4a2243ca870d26d34c2c1bcd3e4425b7bcc5112362df2d93cc7fb9746f6142b5e272fd1cc5c86ddf8580175186f6ad42b
languageName: node
linkType: hard

"pseudomap@npm:^1.0.2":
version: 1.0.2
resolution: "pseudomap@npm:1.0.2"
Expand Down Expand Up @@ -5212,9 +5220,9 @@ __metadata:
languageName: node
linkType: hard

"ws@npm:^8.5.0":
version: 8.14.2
resolution: "ws@npm:8.14.2"
"ws@npm:^8.18.0":
version: 8.18.0
resolution: "ws@npm:8.18.0"
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: ">=5.0.2"
Expand All @@ -5223,7 +5231,7 @@ __metadata:
optional: true
utf-8-validate:
optional: true
checksum: 10c0/35b4c2da048b8015c797fd14bcb5a5766216ce65c8a5965616a5440ca7b6c3681ee3cbd0ea0c184a59975556e9d58f2002abf8485a14d11d3371770811050a16
checksum: 10c0/25eb33aff17edcb90721ed6b0eb250976328533ad3cd1a28a274bd263682e7296a6591ff1436d6cbc50fa67463158b062f9d1122013b361cec99a05f84680e06
languageName: node
linkType: hard

Expand Down

0 comments on commit 898449b

Please sign in to comment.