Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gelatonetwork/relay-sdk

Package Overview
Dependencies
Maintainers
16
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gelatonetwork/relay-sdk - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0-0

dist/utils/generateSalt.d.ts

4

dist/constants/index.d.ts

@@ -10,1 +10,5 @@ export declare const GELATO_RELAY_URL = "https://api.gelato.digital";

export declare const GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS = "0x97015cD4C3d456997DD1C40e2a18c79108FCc412";
export declare const GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS = "0x8598806401A63Ddf52473F1B3C55bC9E33e2d73b";
export declare const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS = "0xc65d82ECE367EF06bf2AB791B3f3CF037Dc0e816";
export declare const GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS = "0xBa4082F4961c8Fb76231995C967CD9aa40f321b5";
export declare const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS = "0xB8828e4c662D1a7e4f3d1f622EfAE6B63D852ED8";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS = exports.GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS = exports.GELATO_RELAY_1BALANCE_ERC2771_ADDRESS = exports.GELATO_RELAY_ERC2771_ADDRESS = exports.USER_NONCE_ABI = exports.DEFAULT_DEADLINE_GAP = exports.DEFAULT_INTERNAL_ERROR_MESSAGE = exports.SIGN_TYPED_DATA_V4 = exports.GELATO_RELAY_URL = void 0;
exports.GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS = exports.GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS = exports.GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS = exports.GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS = exports.GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS = exports.GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS = exports.GELATO_RELAY_1BALANCE_ERC2771_ADDRESS = exports.GELATO_RELAY_ERC2771_ADDRESS = exports.USER_NONCE_ABI = exports.DEFAULT_DEADLINE_GAP = exports.DEFAULT_INTERNAL_ERROR_MESSAGE = exports.SIGN_TYPED_DATA_V4 = exports.GELATO_RELAY_URL = void 0;
exports.GELATO_RELAY_URL = "https://api.gelato.digital"; //Relay GW

@@ -15,1 +15,5 @@ exports.SIGN_TYPED_DATA_V4 = "eth_signTypedData_v4";

exports.GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS = "0x97015cD4C3d456997DD1C40e2a18c79108FCc412";
exports.GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS = "0x8598806401A63Ddf52473F1B3C55bC9E33e2d73b";
exports.GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS = "0xc65d82ECE367EF06bf2AB791B3f3CF037Dc0e816";
exports.GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS = "0xBa4082F4961c8Fb76231995C967CD9aa40f321b5";
exports.GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS = "0xB8828e4c662D1a7e4f3d1f622EfAE6B63D852ED8";

16

dist/index.d.ts
import { ethers } from "ethers";
import { CallWithSyncFeeRequest } from "./lib/callWithSyncFee/types";
import { SponsoredCallRequest } from "./lib/sponsoredCall/types";
import { SignatureData, CallWithERC2771Request, ERC2771Type, CallWithSyncFeeERC2771Request } from "./lib/erc2771/types";
import { SignatureData, CallWithERC2771Request, ERC2771Type, CallWithSyncFeeERC2771Request, CallWithSyncFeeConcurrentERC2771Request, CallWithConcurrentERC2771Request } from "./lib/erc2771/types";
import { TransactionStatusResponse } from "./lib/status/types";
import { BaseCallWithSyncFeeParams, Config, RelayRequestOptions, RelayResponse } from "./lib/types";
export { CallWithSyncFeeRequest, CallWithERC2771Request, SponsoredCallRequest, RelayRequestOptions, TransactionStatusResponse, RelayResponse, SignatureData, ERC2771Type, CallWithSyncFeeERC2771Request, BaseCallWithSyncFeeParams, Config, };
export { CallWithSyncFeeRequest, CallWithERC2771Request, SponsoredCallRequest, RelayRequestOptions, TransactionStatusResponse, RelayResponse, SignatureData, ERC2771Type, CallWithSyncFeeERC2771Request, BaseCallWithSyncFeeParams, CallWithSyncFeeConcurrentERC2771Request, CallWithConcurrentERC2771Request, Config, };
export declare class GelatoRelay {

@@ -24,3 +24,3 @@ #private;

/**
* @param {CallWithSyncFeeERC2771Request} request - CallWithSyncFeeERC2771 request to be relayed by Gelato Executors
* @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

@@ -31,3 +31,3 @@ * @param {RelayRequestOptions} [options] - Optional Relay configuration

*/
callWithSyncFeeERC2771: (request: CallWithSyncFeeERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, options?: RelayRequestOptions) => Promise<RelayResponse>;
callWithSyncFeeERC2771: (request: CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, options?: RelayRequestOptions) => Promise<RelayResponse>;
/**

@@ -42,3 +42,3 @@ * @param {SponsoredCallRequest} request SponsoredCallRequest to be relayed by the Gelato Executors.

/**
* @param {CallWithERC2771Request} request - CallWithERC2771Request to be relayed by Gelato Executors
* @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

@@ -50,5 +50,5 @@ * @param {string} sponsorApiKey - Sponsor API key

*/
sponsoredCallERC2771: (request: CallWithERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, sponsorApiKey: string, options?: RelayRequestOptions) => Promise<RelayResponse>;
sponsoredCallERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, sponsorApiKey: string, options?: RelayRequestOptions) => Promise<RelayResponse>;
/**
* @param {CallWithERC2771Request} request - CallWithERC2771Request to be relayed by Gelato Executors
* @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

@@ -59,3 +59,3 @@ * @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall

*/
getSignatureDataERC2771: (request: CallWithERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, type: ERC2771Type) => Promise<SignatureData>;
getSignatureDataERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, type: ERC2771Type) => Promise<SignatureData>;
/**

@@ -62,0 +62,0 @@ * @param {SignatureData["struct"]} struct - Struct that can be obtained from getSignatureDataERC2771

@@ -53,3 +53,3 @@ "use strict";

this._getConfiguration = (config) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
return {

@@ -62,2 +62,6 @@ url: (_a = config === null || config === void 0 ? void 0 : config.url) !== null && _a !== void 0 ? _a : constants_1.GELATO_RELAY_URL,

relay1BalanceERC2771zkSync: (_j = (_h = config === null || config === void 0 ? void 0 : config.contract) === null || _h === void 0 ? void 0 : _h.relay1BalanceERC2771zkSync) !== null && _j !== void 0 ? _j : constants_1.GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS,
relayConcurrentERC2771: (_l = (_k = config === null || config === void 0 ? void 0 : config.contract) === null || _k === void 0 ? void 0 : _k.relayConcurrentERC2771) !== null && _l !== void 0 ? _l : constants_1.GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS,
relay1BalanceConcurrentERC2771: (_o = (_m = config === null || config === void 0 ? void 0 : config.contract) === null || _m === void 0 ? void 0 : _m.relay1BalanceConcurrentERC2771) !== null && _o !== void 0 ? _o : constants_1.GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS,
relayConcurrentERC2771zkSync: (_q = (_p = config === null || config === void 0 ? void 0 : config.contract) === null || _p === void 0 ? void 0 : _p.relayConcurrentERC2771zkSync) !== null && _q !== void 0 ? _q : constants_1.GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
relay1BalanceConcurrentERC2771zkSync: (_s = (_r = config === null || config === void 0 ? void 0 : config.contract) === null || _r === void 0 ? void 0 : _r.relay1BalanceConcurrentERC2771zkSync) !== null && _s !== void 0 ? _s : constants_1.GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS,
},

@@ -74,3 +78,3 @@ };

/**
* @param {CallWithSyncFeeERC2771Request} request - CallWithSyncFeeERC2771 request to be relayed by Gelato Executors
* @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

@@ -95,3 +99,3 @@ * @param {RelayRequestOptions} [options] - Optional Relay configuration

/**
* @param {CallWithERC2771Request} request - CallWithERC2771Request to be relayed by Gelato Executors
* @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

@@ -110,3 +114,3 @@ * @param {string} sponsorApiKey - Sponsor API key

/**
* @param {CallWithERC2771Request} request - CallWithERC2771Request to be relayed by Gelato Executors
* @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

@@ -113,0 +117,0 @@ * @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall

import { ethers } from "ethers";
import { Config, RelayRequestOptions, RelayResponse } from "../../types";
import { CallWithSyncFeeERC2771Request } from "../types";
import { CallWithSyncFeeConcurrentERC2771Request, CallWithSyncFeeERC2771Request } from "../types";
export declare const relayWithCallWithSyncFeeERC2771: (payload: {
request: CallWithSyncFeeERC2771Request;
request: CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request;
walletOrProvider: ethers.BrowserProvider | ethers.Wallet;
options?: RelayRequestOptions;
}, config: Config) => Promise<RelayResponse>;

@@ -44,15 +44,34 @@ "use strict";

}
const { isRelayContext, feeToken } = request, callWithSyncFeeRequest = __rest(request, ["isRelayContext", "feeToken"]);
const type = types_2.ERC2771Type.CallWithSyncFee;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request: callWithSyncFeeRequest, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(callWithSyncFeeRequest, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, callWithSyncFeeRequest.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.CallWithSyncFeeERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { feeToken, isRelayContext: isRelayContext !== null && isRelayContext !== void 0 ? isRelayContext : true, userSignature: signature, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
}, config);
if (request.isConcurrent) {
const isConcurrent = true;
const { isRelayContext, feeToken } = request, callWithSyncFeeRequest = __rest(request, ["isRelayContext", "feeToken"]);
const type = types_2.ERC2771Type.ConcurrentCallWithSyncFee;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request: callWithSyncFeeRequest, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(callWithSyncFeeRequest, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, callWithSyncFeeRequest.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.CallWithSyncFeeERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { feeToken, isRelayContext: isRelayContext !== null && isRelayContext !== void 0 ? isRelayContext : true, userSignature: signature, chainId: struct.chainId.toString(), isConcurrent }),
}, config);
}
else {
const isConcurrent = false;
const { isRelayContext, feeToken } = request, callWithSyncFeeRequest = __rest(request, ["isRelayContext", "feeToken"]);
const type = types_2.ERC2771Type.CallWithSyncFee;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request: callWithSyncFeeRequest, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(callWithSyncFeeRequest, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, callWithSyncFeeRequest.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.CallWithSyncFeeERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { feeToken, isRelayContext: isRelayContext !== null && isRelayContext !== void 0 ? isRelayContext : true, userSignature: signature, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString(), isConcurrent }),
}, config);
}
}

@@ -59,0 +78,0 @@ catch (error) {

import { BaseCallWithSyncFeeParams, Config, RelayRequestOptions, RelayResponse } from "../../types";
import { CallWithERC2771Struct } from "../types";
import { CallWithConcurrentERC2771Struct, CallWithERC2771Struct } from "../types";
export declare const callWithSyncFeeERC2771WithSignature: (payload: {
struct: CallWithERC2771Struct;
struct: CallWithERC2771Struct | CallWithConcurrentERC2771Struct;
syncFeeParams: BaseCallWithSyncFeeParams;

@@ -6,0 +6,0 @@ signature: string;

@@ -17,3 +17,3 @@ "use strict";

const callWithSyncFeeERC2771WithSignature = (payload, config) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
var _a, _b;
try {

@@ -25,6 +25,16 @@ const { signature, struct, syncFeeParams, options } = payload;

}
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.CallWithSyncFeeERC2771,
request: Object.assign(Object.assign(Object.assign(Object.assign({}, struct), syncFeeParams), options), { isRelayContext: (_a = syncFeeParams.isRelayContext) !== null && _a !== void 0 ? _a : true, userSignature: signature, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
}, config);
if ((0, utils_1.isConcurrentStruct)(struct)) {
const isConcurrent = true;
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.CallWithSyncFeeERC2771,
request: Object.assign(Object.assign(Object.assign(Object.assign({}, struct), syncFeeParams), options), { isRelayContext: (_a = syncFeeParams.isRelayContext) !== null && _a !== void 0 ? _a : true, userSignature: signature, chainId: struct.chainId.toString(), isConcurrent }),
}, config);
}
else {
const isConcurrent = false;
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.CallWithSyncFeeERC2771,
request: Object.assign(Object.assign(Object.assign(Object.assign({}, struct), syncFeeParams), options), { isRelayContext: (_b = syncFeeParams.isRelayContext) !== null && _b !== void 0 ? _b : true, userSignature: signature, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString(), isConcurrent }),
}, config);
}
}

@@ -31,0 +41,0 @@ catch (error) {

import { ethers } from "ethers";
import { Config } from "../../types";
import { SignatureData, CallWithERC2771Request, ERC2771Type } from "../types";
import { SignatureData, CallWithERC2771Request, ERC2771Type, CallWithConcurrentERC2771Request } from "../types";
export declare const getSignatureDataERC2771: (payload: {
request: CallWithERC2771Request;
request: CallWithERC2771Request | CallWithConcurrentERC2771Request;
walletOrProvider: ethers.BrowserProvider | ethers.Wallet;
type: ERC2771Type;
}, config: Config) => Promise<SignatureData>;

@@ -31,13 +31,30 @@ "use strict";

}
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(request, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return {
struct,
signature,
};
if ((0, utils_1.isConcurrentRequest)(request)) {
const concurrentType = type;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request, type: concurrentType, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(request, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return {
struct,
signature,
};
}
else {
const nonConcurrentType = type;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request, type: nonConcurrentType, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(request, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return {
struct,
signature,
};
}
}

@@ -44,0 +61,0 @@ catch (error) {

import { ethers } from "ethers";
import { Config, RelayRequestOptions, RelayResponse } from "../../types";
import { CallWithERC2771Request } from "../types";
import { CallWithConcurrentERC2771Request, CallWithERC2771Request } from "../types";
export declare const relayWithSponsoredCallERC2771: (payload: {
request: CallWithERC2771Request;
request: CallWithERC2771Request | CallWithConcurrentERC2771Request;
walletOrProvider: ethers.BrowserProvider | ethers.Wallet;

@@ -7,0 +7,0 @@ sponsorApiKey: string;

@@ -37,14 +37,32 @@ "use strict";

}
const type = types_2.ERC2771Type.SponsoredCall;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(request, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.SponsoredCallERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { userSignature: signature, sponsorApiKey, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
}, config);
if ((0, utils_1.isConcurrentRequest)(request)) {
const isConcurrent = true;
const type = types_2.ERC2771Type.ConcurrentSponsoredCall;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(request, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.SponsoredCallERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { userSignature: signature, sponsorApiKey, chainId: struct.chainId.toString(), isConcurrent }),
}, config);
}
else {
const isConcurrent = false;
const type = types_2.ERC2771Type.SponsoredCall;
const parametersToOverride = yield (0, utils_1.populateOptionalUserParameters)({ request, type, walletOrProvider }, config);
const struct = yield (0, utils_2.mapRequestToStruct)(request, parametersToOverride);
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, (0, utils_2.getPayloadToSign)({
struct: Object.assign(Object.assign({}, struct), { chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
type,
isWallet: (0, utils_1.isWallet)(walletOrProvider),
}, config));
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.SponsoredCallERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { userSignature: signature, sponsorApiKey, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString(), isConcurrent }),
}, config);
}
}

@@ -51,0 +69,0 @@ catch (error) {

import { Config, RelayRequestOptions, RelayResponse } from "../../types";
import { CallWithERC2771Struct } from "../types";
import { CallWithConcurrentERC2771Struct, CallWithERC2771Struct } from "../types";
export declare const sponsoredCallERC2771WithSignature: (payload: {
struct: CallWithERC2771Struct;
struct: CallWithERC2771Struct | CallWithConcurrentERC2771Struct;
signature: string;

@@ -6,0 +6,0 @@ sponsorApiKey: string;

@@ -23,6 +23,16 @@ "use strict";

}
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.SponsoredCallERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { userSignature: signature, sponsorApiKey, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString() }),
}, config);
if ((0, utils_1.isConcurrentStruct)(struct)) {
const isConcurrent = true;
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.SponsoredCallERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { userSignature: signature, sponsorApiKey, chainId: struct.chainId.toString(), isConcurrent }),
}, config);
}
else {
const isConcurrent = false;
return yield (0, utils_1.post)({
relayCall: types_1.RelayCall.SponsoredCallERC2771,
request: Object.assign(Object.assign(Object.assign({}, struct), options), { userSignature: signature, sponsorApiKey, chainId: struct.chainId.toString(), userNonce: struct.userNonce.toString(), isConcurrent }),
}, config);
}
}

@@ -29,0 +39,0 @@ catch (error) {

@@ -14,2 +14,14 @@ import { BaseCallWithSyncFeeParams, BaseRelayParams, EIP712Domain, Optional, SafeRequestPayload } from "../../types";

};
export declare const EIP712_SPONSORED_CALL_CONCURRENT_ERC2771_TYPE_DATA: {
SponsoredCallConcurrentERC2771: {
name: string;
type: string;
}[];
};
export declare const EIP712_CALL_WITH_SYNC_FEE_CONCURRENT_ERC2771_TYPE_DATA: {
CallWithSyncFeeConcurrentERC2771: {
name: string;
type: string;
}[];
};
export type UserAuthSignature = {

@@ -48,3 +60,34 @@ userSignature: string;

};
export type SponsoredCallConcurrentERC2771PayloadToSign = {
domain: EIP712Domain;
types: {
EIP712Domain?: {
name: string;
type: string;
}[];
SponsoredCallConcurrentERC2771: {
name: string;
type: string;
}[];
};
primaryType?: "SponsoredCallConcurrentERC2771";
message: SafeRequestPayload<CallWithConcurrentERC2771Struct>;
};
export type CallWithSyncFeeConcurrentERC2771PayloadToSign = {
domain: EIP712Domain;
types: {
EIP712Domain?: {
name: string;
type: string;
}[];
CallWithSyncFeeConcurrentERC2771: {
name: string;
type: string;
}[];
};
primaryType?: "CallWithSyncFeeConcurrentERC2771";
message: SafeRequestPayload<CallWithConcurrentERC2771Struct>;
};
export type CallWithERC2771Struct = BaseRelayParams & ERC2771UserParams;
export type CallWithConcurrentERC2771Struct = BaseRelayParams & ConcurrentERC2771UserParams;
export type ERC2771UserParams = {

@@ -55,4 +98,15 @@ user: string;

};
export type CallWithERC2771Request = Optional<CallWithERC2771Struct, keyof CallWithERC2771RequestOptionalParameters>;
export type ConcurrentERC2771UserParams = {
user: string;
userSalt: string;
userDeadline: number;
};
export type CallWithERC2771Request = Optional<CallWithERC2771Struct, keyof CallWithERC2771RequestOptionalParameters> & {
isConcurrent?: false;
};
export type CallWithSyncFeeERC2771Request = CallWithERC2771Request & BaseCallWithSyncFeeParams;
export type CallWithConcurrentERC2771Request = Optional<CallWithConcurrentERC2771Struct, keyof CallWithConcurrentERC2771RequestOptionalParameters> & {
isConcurrent: true;
};
export type CallWithSyncFeeConcurrentERC2771Request = CallWithConcurrentERC2771Request & BaseCallWithSyncFeeParams;
export type CallWithERC2771RequestOptionalParameters = {

@@ -62,4 +116,8 @@ userNonce: bigint;

};
export type CallWithConcurrentERC2771RequestOptionalParameters = {
userDeadline: number;
userSalt: string;
};
export type SignatureData = {
struct: CallWithERC2771Struct;
struct: CallWithERC2771Struct | CallWithConcurrentERC2771Struct;
signature: string;

@@ -69,3 +127,5 @@ };

CallWithSyncFee = "CallWithSyncFee",
SponsoredCall = "SponsoredCall"
SponsoredCall = "SponsoredCall",
ConcurrentCallWithSyncFee = "ConcurrentCallWithSyncFee",
ConcurrentSponsoredCall = "ConcurrentSponsoredCall"
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ERC2771Type = exports.EIP712_CALL_WITH_SYNC_FEE_ERC2771_TYPE_DATA = exports.EIP712_SPONSORED_CALL_ERC2771_TYPE_DATA = void 0;
exports.ERC2771Type = exports.EIP712_CALL_WITH_SYNC_FEE_CONCURRENT_ERC2771_TYPE_DATA = exports.EIP712_SPONSORED_CALL_CONCURRENT_ERC2771_TYPE_DATA = exports.EIP712_CALL_WITH_SYNC_FEE_ERC2771_TYPE_DATA = exports.EIP712_SPONSORED_CALL_ERC2771_TYPE_DATA = void 0;
exports.EIP712_SPONSORED_CALL_ERC2771_TYPE_DATA = {

@@ -24,2 +24,22 @@ SponsoredCallERC2771: [

};
exports.EIP712_SPONSORED_CALL_CONCURRENT_ERC2771_TYPE_DATA = {
SponsoredCallConcurrentERC2771: [
{ name: "chainId", type: "uint256" },
{ name: "target", type: "address" },
{ name: "data", type: "bytes" },
{ name: "user", type: "address" },
{ name: "userSalt", type: "bytes32" },
{ name: "userDeadline", type: "uint256" },
],
};
exports.EIP712_CALL_WITH_SYNC_FEE_CONCURRENT_ERC2771_TYPE_DATA = {
CallWithSyncFeeConcurrentERC2771: [
{ name: "chainId", type: "uint256" },
{ name: "target", type: "address" },
{ name: "data", type: "bytes" },
{ name: "user", type: "address" },
{ name: "userSalt", type: "bytes32" },
{ name: "userDeadline", type: "uint256" },
],
};
var ERC2771Type;

@@ -29,2 +49,4 @@ (function (ERC2771Type) {

ERC2771Type["SponsoredCall"] = "SponsoredCall";
ERC2771Type["ConcurrentCallWithSyncFee"] = "ConcurrentCallWithSyncFee";
ERC2771Type["ConcurrentSponsoredCall"] = "ConcurrentSponsoredCall";
})(ERC2771Type = exports.ERC2771Type || (exports.ERC2771Type = {}));
import { Config, SafeRequestPayload } from "../../types";
import { SponsoredCallERC2771PayloadToSign, CallWithERC2771Struct, ERC2771Type, CallWithSyncFeeERC2771PayloadToSign } from "../types";
export declare const getPayloadToSign: (payload: {
struct: SafeRequestPayload<CallWithERC2771Struct>;
import { SponsoredCallERC2771PayloadToSign, CallWithERC2771Struct, ERC2771Type, CallWithSyncFeeERC2771PayloadToSign, CallWithConcurrentERC2771Struct, SponsoredCallConcurrentERC2771PayloadToSign, CallWithSyncFeeConcurrentERC2771PayloadToSign } from "../types";
export declare function getPayloadToSign(payload: {
struct: SafeRequestPayload<CallWithERC2771Struct | CallWithConcurrentERC2771Struct>;
type: ERC2771Type;
isWallet: boolean;
}, config: Config) => SponsoredCallERC2771PayloadToSign | CallWithSyncFeeERC2771PayloadToSign;
}, config: Config): SponsoredCallERC2771PayloadToSign | CallWithSyncFeeERC2771PayloadToSign | SponsoredCallConcurrentERC2771PayloadToSign | CallWithSyncFeeConcurrentERC2771PayloadToSign;

@@ -7,3 +7,3 @@ "use strict";

const types_2 = require("../types");
const getPayloadToSign = (payload, config) => {
function getPayloadToSign(payload, config) {
const { isWallet, struct, type } = payload;

@@ -40,2 +40,30 @@ const domain = (0, utils_1.getEIP712Domain)({ chainId: BigInt(struct.chainId), type }, config);

};
case types_2.ERC2771Type.ConcurrentSponsoredCall:
if (isWallet) {
return {
domain,
types: Object.assign({}, types_2.EIP712_SPONSORED_CALL_CONCURRENT_ERC2771_TYPE_DATA),
message: struct,
};
}
return {
domain,
types: Object.assign(Object.assign({}, types_2.EIP712_SPONSORED_CALL_CONCURRENT_ERC2771_TYPE_DATA), types_1.EIP712_DOMAIN_TYPE_DATA),
primaryType: "SponsoredCallConcurrentERC2771",
message: struct,
};
case types_2.ERC2771Type.ConcurrentCallWithSyncFee:
if (isWallet) {
return {
domain,
types: Object.assign({}, types_2.EIP712_CALL_WITH_SYNC_FEE_CONCURRENT_ERC2771_TYPE_DATA),
message: struct,
};
}
return {
domain,
types: Object.assign(Object.assign({}, types_2.EIP712_CALL_WITH_SYNC_FEE_CONCURRENT_ERC2771_TYPE_DATA), types_1.EIP712_DOMAIN_TYPE_DATA),
primaryType: "CallWithSyncFeeConcurrentERC2771",
message: struct,
};
default:

@@ -46,3 +74,3 @@ // eslint-disable-next-line no-case-declarations

}
};
}
exports.getPayloadToSign = getPayloadToSign;

@@ -1,2 +0,3 @@

import { CallWithERC2771Request, CallWithERC2771RequestOptionalParameters, CallWithERC2771Struct } from "../types";
export declare const mapRequestToStruct: (request: CallWithERC2771Request, override: Partial<CallWithERC2771RequestOptionalParameters>) => Promise<CallWithERC2771Struct>;
import { CallWithConcurrentERC2771Request, CallWithConcurrentERC2771RequestOptionalParameters, CallWithConcurrentERC2771Struct, CallWithERC2771Request, CallWithERC2771RequestOptionalParameters, CallWithERC2771Struct } from "../types";
export declare function mapRequestToStruct(request: CallWithConcurrentERC2771Request, override: Partial<CallWithConcurrentERC2771RequestOptionalParameters>): Promise<CallWithConcurrentERC2771Struct>;
export declare function mapRequestToStruct(request: CallWithERC2771Request, override: Partial<CallWithERC2771RequestOptionalParameters>): Promise<CallWithERC2771Struct>;

@@ -14,24 +14,39 @@ "use strict";

const ethers_1 = require("ethers");
const mapRequestToStruct = (request, override) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
if (override.userNonce === undefined && request.userNonce === undefined) {
throw new Error(`userNonce is not found in the request, nor fetched`);
}
if (!override.userDeadline && !request.userDeadline) {
throw new Error(`userDeadline is not found in the request, nor fetched`);
}
return {
userNonce: override.userNonce !== undefined
? override.userNonce
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
request.userNonce,
userDeadline:
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(_a = override.userDeadline) !== null && _a !== void 0 ? _a : request.userDeadline,
chainId: request.chainId,
target: (0, ethers_1.getAddress)(request.target),
data: request.data,
user: (0, ethers_1.getAddress)(request.user),
};
});
const utils_1 = require("../../../utils");
function mapRequestToStruct(request, override) {
var _a, _b, _c;
return __awaiter(this, void 0, void 0, function* () {
if (!override.userDeadline && !request.userDeadline) {
throw new Error(`userDeadline is not found in the request, nor fetched`);
}
if ((0, utils_1.isConcurrentRequest)(request)) {
const concurrentOverride = override;
return {
userDeadline: (_a = concurrentOverride.userDeadline) !== null && _a !== void 0 ? _a : request.userDeadline,
chainId: request.chainId,
target: (0, ethers_1.getAddress)(request.target),
data: request.data,
user: (0, ethers_1.getAddress)(request.user),
userSalt: (_b = concurrentOverride.userSalt) !== null && _b !== void 0 ? _b : request.userSalt,
};
}
else {
const nonConcurrentOverride = override;
if (nonConcurrentOverride.userNonce === undefined &&
request.userNonce === undefined) {
throw new Error(`userNonce is not found in the request, nor fetched`);
}
return {
userDeadline: (_c = nonConcurrentOverride.userDeadline) !== null && _c !== void 0 ? _c : request.userDeadline,
chainId: request.chainId,
target: (0, ethers_1.getAddress)(request.target),
data: request.data,
user: (0, ethers_1.getAddress)(request.user),
userNonce: nonConcurrentOverride.userNonce !== undefined
? nonConcurrentOverride.userNonce
: request.userNonce,
};
}
});
}
exports.mapRequestToStruct = mapRequestToStruct;

@@ -13,2 +13,5 @@ import { BytesLike } from "ethers";

};
export type ConcurrencyOptions = {
isConcurrent: boolean;
};
export type ApiKey = {

@@ -48,2 +51,6 @@ sponsorApiKey: string;

relay1BalanceERC2771zkSync: string;
relayConcurrentERC2771: string;
relay1BalanceConcurrentERC2771: string;
relayConcurrentERC2771zkSync: string;
relay1BalanceConcurrentERC2771zkSync: string;
};

@@ -50,0 +57,0 @@ };

@@ -23,2 +23,16 @@ "use strict";

};
case types_1.ERC2771Type.ConcurrentCallWithSyncFee:
return {
name: "GelatoRelayConcurrentERC2771",
version: "1",
chainId: chainId.toString(),
verifyingContract: (0, relayAddress_1.getGelatoRelayERC2771Address)({ chainId, type }, config),
};
case types_1.ERC2771Type.ConcurrentSponsoredCall:
return {
name: "GelatoRelay1BalanceConcurrentERC2771",
version: "1",
chainId: chainId.toString(),
verifyingContract: (0, relayAddress_1.getGelatoRelayERC2771Address)({ chainId, type }, config),
};
default:

@@ -25,0 +39,0 @@ // eslint-disable-next-line no-case-declarations

@@ -13,1 +13,4 @@ export * from "./signTypedDataV4";

export * from "./axios";
export * from "./isConcurrentStruct";
export * from "./isConcurrentRequest";
export * from "./generateSalt";

@@ -29,1 +29,4 @@ "use strict";

__exportStar(require("./axios"), exports);
__exportStar(require("./isConcurrentStruct"), exports);
__exportStar(require("./isConcurrentRequest"), exports);
__exportStar(require("./generateSalt"), exports);
import { ethers } from "ethers";
import { CallWithERC2771Request, CallWithERC2771RequestOptionalParameters, ERC2771Type } from "../lib/erc2771/types";
import { CallWithConcurrentERC2771Request, CallWithConcurrentERC2771RequestOptionalParameters, CallWithERC2771Request, CallWithERC2771RequestOptionalParameters, ERC2771Type } from "../lib/erc2771/types";
import { Config } from "../lib/types";
export declare const populateOptionalUserParameters: <Request extends CallWithERC2771Request, OptionalParameters extends CallWithERC2771RequestOptionalParameters>(payload: {
request: Request;
type: ERC2771Type;
export declare function populateOptionalUserParameters(payload: {
request: CallWithConcurrentERC2771Request;
type: ERC2771Type.ConcurrentCallWithSyncFee | ERC2771Type.ConcurrentSponsoredCall;
walletOrProvider: ethers.BrowserProvider | ethers.Wallet;
}, config: Config) => Promise<Partial<OptionalParameters>>;
}, config: Config): Promise<Partial<CallWithConcurrentERC2771RequestOptionalParameters>>;
export declare function populateOptionalUserParameters(payload: {
request: CallWithERC2771Request;
type: ERC2771Type.CallWithSyncFee | ERC2771Type.SponsoredCall;
walletOrProvider: ethers.BrowserProvider | ethers.Wallet;
}, config: Config): Promise<Partial<CallWithERC2771RequestOptionalParameters>>;

@@ -16,17 +16,36 @@ "use strict";

const getUserNonce_1 = require("./getUserNonce");
const populateOptionalUserParameters = (payload, config) => __awaiter(void 0, void 0, void 0, function* () {
const { request, type, walletOrProvider } = payload;
const parametersToOverride = {};
if (!request.userDeadline) {
parametersToOverride.userDeadline = (0, calculateDeadline_1.calculateDeadline)(constants_1.DEFAULT_DEADLINE_GAP);
}
if (request.userNonce === undefined) {
parametersToOverride.userNonce = yield (0, getUserNonce_1.getUserNonce)({
account: request.user,
type,
walletOrProvider,
}, config);
}
return parametersToOverride;
});
const isConcurrentRequest_1 = require("./isConcurrentRequest");
const generateSalt_1 = require("./generateSalt");
function populateOptionalUserParameters(payload, config) {
return __awaiter(this, void 0, void 0, function* () {
if ((0, isConcurrentRequest_1.isConcurrentRequest)(payload.request)) {
const { request } = payload;
const parametersToOverride = {};
if (!request.userDeadline) {
parametersToOverride.userDeadline =
(0, calculateDeadline_1.calculateDeadline)(constants_1.DEFAULT_DEADLINE_GAP);
}
if (!request.userSalt) {
parametersToOverride.userSalt = (0, generateSalt_1.generateSalt)();
}
return parametersToOverride;
}
else {
const { type, walletOrProvider, request } = payload;
const parametersToOverride = {};
if (!request.userDeadline) {
parametersToOverride.userDeadline =
(0, calculateDeadline_1.calculateDeadline)(constants_1.DEFAULT_DEADLINE_GAP);
}
if (request.userNonce === undefined) {
parametersToOverride.userNonce = yield (0, getUserNonce_1.getUserNonce)({
account: request.user,
type,
walletOrProvider,
}, config);
}
return parametersToOverride;
}
});
}
exports.populateOptionalUserParameters = populateOptionalUserParameters;

@@ -18,2 +18,10 @@ "use strict";

: (0, ethers_1.getAddress)(config.contract.relay1BalanceERC2771);
case types_1.ERC2771Type.ConcurrentCallWithSyncFee:
return (0, isZkSync_1.isZkSync)(chainId)
? (0, ethers_1.getAddress)(config.contract.relayConcurrentERC2771zkSync)
: (0, ethers_1.getAddress)(config.contract.relayConcurrentERC2771);
case types_1.ERC2771Type.ConcurrentSponsoredCall:
return (0, isZkSync_1.isZkSync)(chainId)
? (0, ethers_1.getAddress)(config.contract.relay1BalanceConcurrentERC2771zkSync)
: (0, ethers_1.getAddress)(config.contract.relay1BalanceConcurrentERC2771);
default:

@@ -20,0 +28,0 @@ // eslint-disable-next-line no-case-declarations

import { ethers } from "ethers";
import { CallWithSyncFeeERC2771PayloadToSign, SponsoredCallERC2771PayloadToSign } from "../lib/erc2771/types";
export declare const signTypedDataV4: (walletOrProvider: ethers.BrowserProvider | ethers.Wallet, address: string, payload: SponsoredCallERC2771PayloadToSign | CallWithSyncFeeERC2771PayloadToSign) => Promise<string>;
import { CallWithSyncFeeERC2771PayloadToSign, SponsoredCallERC2771PayloadToSign, SponsoredCallConcurrentERC2771PayloadToSign, CallWithSyncFeeConcurrentERC2771PayloadToSign } from "../lib/erc2771/types";
export declare const signTypedDataV4: (walletOrProvider: ethers.BrowserProvider | ethers.Wallet, address: string, payload: SponsoredCallERC2771PayloadToSign | CallWithSyncFeeERC2771PayloadToSign | SponsoredCallConcurrentERC2771PayloadToSign | CallWithSyncFeeConcurrentERC2771PayloadToSign) => Promise<string>;
{
"name": "@gelatonetwork/relay-sdk",
"version": "5.0.0",
"version": "5.1.0-0",
"description": "SDK to integrate with Gelato Relay",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc