Skip to content

Commit

Permalink
fix: conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
opatavi committed Sep 20, 2023
2 parents ab88477 + ba09a76 commit 2344881
Show file tree
Hide file tree
Showing 40 changed files with 2,376 additions and 1,521 deletions.
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gelatonetwork/relay-sdk",
"version": "3.5.0",
"version": "5.2.0",
"description": "SDK to integrate with Gelato Relay",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -14,29 +14,32 @@
"lint": "eslint --cache .",
"prepare": "husky install"
},
"engines": {
"node": ">=14.0.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@tsconfig/recommended": "1.0.1",
"@types/node": "16.11.12",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"dotenv": "^16.0.2",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^3.1.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.1.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"minimize-js": "^1.3.0",
"prettier": "^2.7.1",
"typescript": "4.5.3"
"@tsconfig/recommended": "1.0.2",
"@types/node": "16.18.25",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"dotenv": "^16.0.3",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"minimize-js": "^1.3.1",
"prettier": "^2.8.8",
"typescript": "5.0.4"
},
"dependencies": {
"axios": "0.24.0",
"ethers": "5.7.2"
"axios": "0.27.2",
"ethers": "6.7.0"
},
"lint-staged": {
"*.{js,json,md,ts}": "yarn format",
Expand Down
19 changes: 18 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,21 @@ export const USER_NONCE_ABI = [
];

export const GELATO_RELAY_ERC2771_ADDRESS =
"0xBf175FCC7086b4f9bd59d5EAE8eA67b8f940DE0d";
"0xb539068872230f20456CF38EC52EF2f91AF4AE49";
export const GELATO_RELAY_1BALANCE_ERC2771_ADDRESS =
"0xd8253782c45a12053594b9deB72d8e8aB2Fca54c";

export const GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS =
"0x22DCC39b2AC376862183dd35A1664798dafC7Da6";
export const GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS =
"0x97015cD4C3d456997DD1C40e2a18c79108FCc412";

export const GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS =
"0x8598806401A63Ddf52473F1B3C55bC9E33e2d73b";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS =
"0xc65d82ECE367EF06bf2AB791B3f3CF037Dc0e816";

export const GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS =
"0xBa4082F4961c8Fb76231995C967CD9aa40f321b5";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS =
"0xB8828e4c662D1a7e4f3d1f622EfAE6B63D852ED8";
114 changes: 85 additions & 29 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { BigNumber, ethers } from "ethers";
import { ethers } from "ethers";

import * as library from "./lib";
import { CallWithSyncFeeRequest } from "./lib/callWithSyncFee/types";
import { SponsoredCallRequest } from "./lib/sponsoredCall/types";
import {
SignatureData,
PayloadToSign,
CallWithERC2771Request,
ERC2771Type,
CallWithSyncFeeERC2771Request,
CallWithSyncFeeConcurrentERC2771Request,
CallWithConcurrentERC2771Request,
} from "./lib/erc2771/types";
import { TransactionStatusResponse } from "./lib/status/types";
import {
Expand All @@ -16,7 +19,17 @@ import {
RelayRequestOptions,
RelayResponse,
} from "./lib/types";
import { GELATO_RELAY_ERC2771_ADDRESS, GELATO_RELAY_URL } from "./constants";
import {
GELATO_RELAY_1BALANCE_ERC2771_ADDRESS,
GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS,
GELATO_RELAY_ERC2771_ADDRESS,
GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS,
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS,
GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS,
GELATO_RELAY_URL,
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
} from "./constants";

export {
CallWithSyncFeeRequest,
Expand All @@ -26,9 +39,12 @@ export {
TransactionStatusResponse,
RelayResponse,
SignatureData,
PayloadToSign,
ERC2771Type,
CallWithSyncFeeERC2771Request,
BaseCallWithSyncFeeParams,
CallWithSyncFeeConcurrentERC2771Request,
CallWithConcurrentERC2771Request,
Config,
};
export class GelatoRelay {
Expand All @@ -51,6 +67,27 @@ export class GelatoRelay {
contract: {
relayERC2771:
config?.contract?.relayERC2771 ?? GELATO_RELAY_ERC2771_ADDRESS,
relay1BalanceERC2771:
config?.contract?.relay1BalanceERC2771 ??
GELATO_RELAY_1BALANCE_ERC2771_ADDRESS,
relayERC2771zkSync:
config?.contract?.relayERC2771zkSync ??
GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS,
relay1BalanceERC2771zkSync:
config?.contract?.relay1BalanceERC2771zkSync ??
GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS,
relayConcurrentERC2771:
config?.contract?.relayConcurrentERC2771 ??
GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS,
relay1BalanceConcurrentERC2771:
config?.contract?.relay1BalanceConcurrentERC2771 ??
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS,
relayConcurrentERC2771zkSync:
config?.contract?.relayConcurrentERC2771zkSync ??
GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
relay1BalanceConcurrentERC2771zkSync:
config?.contract?.relay1BalanceConcurrentERC2771zkSync ??
GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
},
};
};
Expand All @@ -70,16 +107,18 @@ export class GelatoRelay {
library.relayWithSyncFee({ request, sponsorApiKey, options }, this.#config);

/**
* @param {CallWithSyncFeeERC2771Request} request - CallWithSyncFeeERC2771 request to be relayed by Gelato Executors
* @param {ethers.providers.Web3Provider | ethers.Wallet} walletOrProvider - Web3Provider [front-end] or Wallet [back-end] to sign the payload
* @param {CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request} request - Call with sync fee: Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors
* @param {ethers.BrowserProvider | ethers.Wallet} walletOrProvider - BrowserProvider [front-end] or Wallet [back-end] to sign the payload
* @param {string} [sponsorApiKey] Optional Sponsor API key to be used for the call
* @param {RelayRequestOptions} [options] - Optional Relay configuration
* @returns {Promise<RelayResponse>} Response object with taskId parameter
*
*/
callWithSyncFeeERC2771 = (
request: CallWithSyncFeeERC2771Request,
walletOrProvider: ethers.providers.Web3Provider | ethers.Wallet,
request:
| CallWithSyncFeeERC2771Request
| CallWithSyncFeeConcurrentERC2771Request,
walletOrProvider: ethers.BrowserProvider | ethers.Wallet,
sponsorApiKey?: string,
options?: RelayRequestOptions
): Promise<RelayResponse> =>
Expand Down Expand Up @@ -111,16 +150,16 @@ export class GelatoRelay {
);

/**
* @param {CallWithERC2771Request} request - CallWithERC2771Request to be relayed by Gelato Executors
* @param {ethers.providers.Web3Provider | ethers.Wallet} walletOrProvider - Web3Provider [front-end] or Wallet [back-end] to sign the payload
* @param {CallWithERC2771Request | CallWithConcurrentERC2771Request} request - Sponsored: Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors
* @param {ethers.BrowserProvider | ethers.Wallet} walletOrProvider - BrowserProvider [front-end] or Wallet [back-end] to sign the payload
* @param {string} sponsorApiKey - Sponsor API key
* @param {RelayRequestOptions} [options] - Optional Relay configuration
* @returns {Promise<RelayResponse>} Response object with taskId parameter
*
*/
sponsoredCallERC2771 = (
request: CallWithERC2771Request,
walletOrProvider: ethers.providers.Web3Provider | ethers.Wallet,
request: CallWithERC2771Request | CallWithConcurrentERC2771Request,
walletOrProvider: ethers.BrowserProvider | ethers.Wallet,
sponsorApiKey: string,
options?: RelayRequestOptions
): Promise<RelayResponse> =>
Expand All @@ -135,22 +174,39 @@ export class GelatoRelay {
);

/**
* @param {CallWithERC2771Request} request - CallWithERC2771Request to be relayed by Gelato Executors
* @param {ethers.providers.Web3Provider | ethers.Wallet} walletOrProvider - Web3Provider [front-end] or Wallet [back-end] to sign the payload
* @param {CallWithERC2771Request | CallWithConcurrentERC2771Request} request - Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors
* @param {ethers.BrowserProvider | ethers.Wallet} walletOrProvider - BrowserProvider [front-end] or Wallet [back-end] to sign the payload
* @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall
* @returns {Promise<SignatureData>} Response object with taskId parameter
* @returns {Promise<SignatureData>} Response object with struct and signature
*
*/
getSignatureDataERC2771 = (
request: CallWithERC2771Request,
walletOrProvider: ethers.providers.Web3Provider | ethers.Wallet,
request: CallWithERC2771Request | CallWithConcurrentERC2771Request,
walletOrProvider: ethers.BrowserProvider | ethers.Wallet,
type: ERC2771Type
): Promise<SignatureData> =>
library.getSignatureDataERC2771(
{ request, walletOrProvider, type },
this.#config
);

/**
* @param {CallWithERC2771Request | CallWithConcurrentERC2771Request} request - Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors
* @param {ethers.BrowserProvider | ethers.Wallet} [walletOrProvider] - Optional BrowserProvider [front-end] or Wallet [back-end] to sign the payload
* @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall
* @returns {Promise<PayloadToSign>} Response object with struct and typed data
*
*/
getDataToSignERC2771 = (
request: CallWithERC2771Request | CallWithConcurrentERC2771Request,
type: ERC2771Type,
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet
): Promise<PayloadToSign> =>
library.getDataToSignERC2771(
{ request, walletOrProvider, type },
this.#config
);

/**
* @param {SignatureData["struct"]} struct - Struct that can be obtained from getSignatureDataERC2771
* @param {SignatureData["signature"]} signature - Signature that can be obtained from getSignatureDataERC2771
Expand Down Expand Up @@ -200,10 +256,10 @@ export class GelatoRelay {
);

/**
* @param {number} chainId - Chain Id
* @param {bigint} chainId - Chain Id
* @returns {Promise<boolean>} Boolean to demonstrate if Relay V2 is supported on the provided chain
*/
isNetworkSupported = (chainId: number): Promise<boolean> =>
isNetworkSupported = (chainId: bigint): Promise<boolean> =>
library.isNetworkSupported({ chainId }, this.#config);

/**
Expand All @@ -213,10 +269,10 @@ export class GelatoRelay {
library.getSupportedNetworks(this.#config);

/**
* @param {number} chainId - Chain Id
* @param {bigint} chainId - Chain Id
* @returns {Promise<boolean>} Boolean to demonstrate if the oracle is active on the provided chain
*/
isOracleActive = (chainId: number): Promise<boolean> =>
isOracleActive = (chainId: bigint): Promise<boolean> =>
library.isOracleActive({ chainId }, this.#config);

/**
Expand All @@ -226,29 +282,29 @@ export class GelatoRelay {
library.getGelatoOracles(this.#config);

/**
* @param {number} chainId - Chain Id
* @param {bigint} chainId - Chain Id
* @returns {Promise<string[]>} List of all payment tokens on the provided chain
*
*/
getPaymentTokens = (chainId: number): Promise<string[]> =>
getPaymentTokens = (chainId: bigint): Promise<string[]> =>
library.getPaymentTokens({ chainId }, this.#config);

/**
* @param {number} chainId - Chain Id
* @param {bigint} chainId - Chain Id
* @param {string} paymentToken - Payment Token
* @param {BigNumber} gasLimit - Gas Limit
* @param {bigint} gasLimit - Gas Limit
* @param {boolean} isHighPriority - Priority Level
* @param {BigNumber} [gasLimitL1=BigNumber.from(0)] - Gas Limit for Layer 1
* @returns {Promise<BigNumber>} Estimated Fee
* @param {bigint} [gasLimitL1=BigInt(0)] - Gas Limit for Layer 1
* @returns {Promise<bigint>} Estimated Fee
*
*/
getEstimatedFee = (
chainId: number,
chainId: bigint,
paymentToken: string,
gasLimit: BigNumber,
gasLimit: bigint,
isHighPriority: boolean,
gasLimitL1: BigNumber = BigNumber.from(0)
): Promise<BigNumber> =>
gasLimitL1 = BigInt(0)
): Promise<bigint> =>
library.getEstimatedFee(
{ chainId, paymentToken, gasLimit, isHighPriority, gasLimitL1 },
this.#config
Expand Down
3 changes: 2 additions & 1 deletion src/lib/callWithSyncFee/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const relayWithSyncFee = async (
try {
const { request, options, sponsorApiKey } = payload;
const isSupported = await isNetworkSupported(
{ chainId: Number(request.chainId) },
{ chainId: request.chainId },
config
);
if (!isSupported) {
Expand All @@ -41,6 +41,7 @@ export const relayWithSyncFee = async (
isRelayContext: request.isRelayContext ?? true,
...options,
sponsorApiKey,
chainId: request.chainId.toString(),
},
},
config
Expand Down
Loading

0 comments on commit 2344881

Please sign in to comment.