Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add abstract #3

Merged
merged 3 commits into from
Feb 3, 2025
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gelatonetwork/relay-sdk-viem",
"version": "1.2.0",
"version": "1.3.0",
"description": "SDK to integrate with Gelato Relay with viem",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -39,14 +39,14 @@
},
"dependencies": {
"@changesets/cli": "^2.27.1",
"axios": "1.7.7",
"axios": "1.7.9",
"isomorphic-ws": "^5.0.0",
"viem": "2.20.1",
"ws": "^8.5.0"
"ws": "^8.18.0"
},
"lint-staged": {
"*.{js,json,md,ts}": "yarn format",
"*.{ts,js}": "yarn lint"
},
"packageManager": "yarn@4.1.1"
}
}
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
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
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,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:1.7.7"
axios: "npm:1.7.9"
dotenv: "npm:^16.0.3"
eslint: "npm:^8.39.0"
eslint-config-prettier: "npm:^8.8.0"
Expand All @@ -511,7 +511,7 @@ __metadata:
prettier: "npm:^2.8.8"
typescript: "npm:5.0.4"
viem: "npm:2.20.1"
ws: "npm:^8.5.0"
ws: "npm:^8.18.0"
languageName: unknown
linkType: soft

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

"axios@npm:1.7.7":
version: 1.7.7
resolution: "axios@npm:1.7.7"
"axios@npm:1.7.9":
version: 1.7.9
resolution: "axios@npm:1.7.9"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.0"
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/4499efc89e86b0b49ffddc018798de05fab26e3bf57913818266be73279a6418c3ce8f9e934c7d2d707ab8c095e837fc6c90608fb7715b94d357720b5f568af7
checksum: 10c0/b7a41e24b59fee5f0f26c1fc844b45b17442832eb3a0fb42dd4f1430eb4abc571fe168e67913e8a1d91c993232bd1d1ab03e20e4d1fee8c6147649b576fc1b0b
languageName: node
linkType: hard

Expand Down Expand Up @@ -4689,9 +4689,9 @@ __metadata:
languageName: node
linkType: hard

"ws@npm:^8.5.0":
version: 8.16.0
resolution: "ws@npm:8.16.0"
"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 @@ -4700,7 +4700,7 @@ __metadata:
optional: true
utf-8-validate:
optional: true
checksum: 10c0/a7783bb421c648b1e622b423409cb2a58ac5839521d2f689e84bc9dc41d59379c692dd405b15a997ea1d4c0c2e5314ad707332d0c558f15232d2bc07c0b4618a
checksum: 10c0/25eb33aff17edcb90721ed6b0eb250976328533ad3cd1a28a274bd263682e7296a6591ff1436d6cbc50fa67463158b062f9d1122013b361cec99a05f84680e06
languageName: node
linkType: hard

Expand Down
Loading