@gelatonetwork/relay-sdk
Advanced tools
Comparing version 5.3.0 to 5.4.0
@@ -1,2 +0,1 @@ | ||
import { ethers } from "ethers"; | ||
import { CallWithSyncFeeRequest } from "./lib/callWithSyncFee/types"; | ||
@@ -6,4 +5,4 @@ import { SponsoredCallRequest } from "./lib/sponsoredCall/types"; | ||
import { TransactionStatusResponse } from "./lib/status/types"; | ||
import { BaseCallWithSyncFeeParams, Config, RelayRequestOptions, RelayResponse } from "./lib/types"; | ||
export { CallWithSyncFeeRequest, CallWithERC2771Request, SponsoredCallRequest, RelayRequestOptions, TransactionStatusResponse, RelayResponse, SignatureData, PayloadToSign, ERC2771Type, CallWithSyncFeeERC2771Request, BaseCallWithSyncFeeParams, CallWithSyncFeeConcurrentERC2771Request, CallWithConcurrentERC2771Request, Config, }; | ||
import { BaseCallWithSyncFeeParams, Config, RelayRequestOptions, RelayResponse, SignerOrProvider } from "./lib/types"; | ||
export { CallWithSyncFeeRequest, CallWithERC2771Request, SponsoredCallRequest, RelayRequestOptions, TransactionStatusResponse, RelayResponse, SignatureData, PayloadToSign, ERC2771Type, CallWithSyncFeeERC2771Request, BaseCallWithSyncFeeParams, CallWithSyncFeeConcurrentERC2771Request, CallWithConcurrentERC2771Request, Config, SignerOrProvider, }; | ||
export declare class GelatoRelay { | ||
@@ -27,3 +26,3 @@ #private; | ||
* @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 {SignerOrProvider} signerOrProvider - BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {RelayRequestOptions} [options] - Optional Relay configuration | ||
@@ -34,3 +33,3 @@ * @param {string} [sponsorApiKey] Optional Sponsor API key to be used for the call | ||
*/ | ||
callWithSyncFeeERC2771: (request: CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, options?: RelayRequestOptions, sponsorApiKey?: string) => Promise<RelayResponse>; | ||
callWithSyncFeeERC2771: (request: CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request, signerOrProvider: SignerOrProvider, options?: RelayRequestOptions, sponsorApiKey?: string) => Promise<RelayResponse>; | ||
/** | ||
@@ -46,3 +45,3 @@ * @param {SponsoredCallRequest} request SponsoredCallRequest to be relayed by the 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 | ||
* @param {SignerOrProvider} signerOrProvider - BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {string} sponsorApiKey - Sponsor API key | ||
@@ -53,6 +52,6 @@ * @param {RelayRequestOptions} [options] - Optional Relay configuration | ||
*/ | ||
sponsoredCallERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, sponsorApiKey: string, options?: RelayRequestOptions) => Promise<RelayResponse>; | ||
sponsoredCallERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, signerOrProvider: SignerOrProvider, sponsorApiKey: string, options?: RelayRequestOptions) => Promise<RelayResponse>; | ||
/** | ||
* @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 {SignerOrProvider} signerOrProvider - BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall | ||
@@ -62,6 +61,6 @@ * @returns {Promise<SignatureData>} Response object with struct and signature | ||
*/ | ||
getSignatureDataERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, walletOrProvider: ethers.BrowserProvider | ethers.Wallet, type: ERC2771Type) => Promise<SignatureData>; | ||
getSignatureDataERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, signerOrProvider: SignerOrProvider, type: ERC2771Type) => Promise<SignatureData>; | ||
/** | ||
* @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 {SignerOrProvider} [signerOrProvider] - Optional BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall | ||
@@ -71,3 +70,3 @@ * @returns {Promise<PayloadToSign>} Response object with struct and typed data | ||
*/ | ||
getDataToSignERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, type: ERC2771Type, walletOrProvider?: ethers.BrowserProvider | ethers.Wallet) => Promise<PayloadToSign>; | ||
getDataToSignERC2771: (request: CallWithERC2771Request | CallWithConcurrentERC2771Request, type: ERC2771Type, signerOrProvider?: SignerOrProvider) => Promise<PayloadToSign>; | ||
/** | ||
@@ -74,0 +73,0 @@ * @param {SignatureData["struct"]} struct - Struct that can be obtained from getSignatureDataERC2771 |
@@ -78,3 +78,3 @@ "use strict"; | ||
* @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 {SignerOrProvider} signerOrProvider - BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {RelayRequestOptions} [options] - Optional Relay configuration | ||
@@ -85,5 +85,5 @@ * @param {string} [sponsorApiKey] Optional Sponsor API key to be used for the call | ||
*/ | ||
this.callWithSyncFeeERC2771 = (request, walletOrProvider, options, sponsorApiKey) => library.relayWithCallWithSyncFeeERC2771({ | ||
this.callWithSyncFeeERC2771 = (request, signerOrProvider, options, sponsorApiKey) => library.relayWithCallWithSyncFeeERC2771({ | ||
request, | ||
walletOrProvider, | ||
signerOrProvider, | ||
sponsorApiKey, | ||
@@ -102,3 +102,3 @@ options, | ||
* @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 {SignerOrProvider} signerOrProvider - BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {string} sponsorApiKey - Sponsor API key | ||
@@ -109,5 +109,5 @@ * @param {RelayRequestOptions} [options] - Optional Relay configuration | ||
*/ | ||
this.sponsoredCallERC2771 = (request, walletOrProvider, sponsorApiKey, options) => library.relayWithSponsoredCallERC2771({ | ||
this.sponsoredCallERC2771 = (request, signerOrProvider, sponsorApiKey, options) => library.relayWithSponsoredCallERC2771({ | ||
request, | ||
walletOrProvider, | ||
signerOrProvider, | ||
sponsorApiKey, | ||
@@ -118,3 +118,3 @@ options, | ||
* @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 {SignerOrProvider} signerOrProvider - BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall | ||
@@ -124,6 +124,6 @@ * @returns {Promise<SignatureData>} Response object with struct and signature | ||
*/ | ||
this.getSignatureDataERC2771 = (request, walletOrProvider, type) => library.getSignatureDataERC2771({ request, walletOrProvider, type }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.getSignatureDataERC2771 = (request, signerOrProvider, type) => library.getSignatureDataERC2771({ request, signerOrProvider, type }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
/** | ||
* @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 {SignerOrProvider} [signerOrProvider] - Optional BrowserProvider [front-end] or Signer [back-end] to sign the payload | ||
* @param {ERC2771Type} type - ERC2771Type.CallWithSyncFee or ERC2771Type.SponsoredCall | ||
@@ -133,3 +133,3 @@ * @returns {Promise<PayloadToSign>} Response object with struct and typed data | ||
*/ | ||
this.getDataToSignERC2771 = (request, type, walletOrProvider) => library.getDataToSignERC2771({ request, walletOrProvider, type }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.getDataToSignERC2771 = (request, type, signerOrProvider) => library.getDataToSignERC2771({ request, signerOrProvider, type }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
/** | ||
@@ -136,0 +136,0 @@ * @param {SignatureData["struct"]} struct - Struct that can be obtained from getSignatureDataERC2771 |
@@ -1,9 +0,8 @@ | ||
import { ethers } from "ethers"; | ||
import { Config, RelayRequestOptions, RelayResponse } from "../../types"; | ||
import { Config, RelayRequestOptions, RelayResponse, SignerOrProvider } from "../../types"; | ||
import { CallWithSyncFeeConcurrentERC2771Request, CallWithSyncFeeERC2771Request } from "../types"; | ||
export declare const relayWithCallWithSyncFeeERC2771: (payload: { | ||
request: CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request; | ||
walletOrProvider: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider: SignerOrProvider; | ||
sponsorApiKey?: string; | ||
options?: RelayRequestOptions; | ||
}, config: Config) => Promise<RelayResponse>; |
@@ -20,6 +20,3 @@ "use strict"; | ||
try { | ||
const { request, walletOrProvider, options, sponsorApiKey } = payload; | ||
if (!walletOrProvider.provider) { | ||
throw new Error(`Missing provider`); | ||
} | ||
const { request, signerOrProvider, options, sponsorApiKey } = payload; | ||
if (request.isConcurrent) { | ||
@@ -29,3 +26,3 @@ const isConcurrent = true; | ||
const type = types_2.ERC2771Type.ConcurrentCallWithSyncFee; | ||
const { struct, signature } = yield (0, index_js_1.getSignatureDataERC2771)({ request, walletOrProvider, type }, config); | ||
const { struct, signature } = yield (0, index_js_1.getSignatureDataERC2771)({ request, signerOrProvider, type }, config); | ||
return yield (0, utils_1.post)({ | ||
@@ -43,3 +40,3 @@ relayCall: types_1.RelayCall.CallWithSyncFeeERC2771, | ||
const type = types_2.ERC2771Type.CallWithSyncFee; | ||
const { struct, signature } = yield (0, index_js_1.getSignatureDataERC2771)({ request, walletOrProvider, type }, config); | ||
const { struct, signature } = yield (0, index_js_1.getSignatureDataERC2771)({ request, signerOrProvider, type }, config); | ||
return yield (0, utils_1.post)({ | ||
@@ -46,0 +43,0 @@ relayCall: types_1.RelayCall.CallWithSyncFeeERC2771, |
@@ -1,3 +0,2 @@ | ||
import { ethers } from "ethers"; | ||
import { Config } from "../../types"; | ||
import { Config, SignerOrProvider } from "../../types"; | ||
import { CallWithERC2771Request, ERC2771Type, CallWithConcurrentERC2771Request, PayloadToSign, SequentialPayloadToSign, ConcurrentPayloadToSign } from "../types"; | ||
@@ -7,3 +6,3 @@ export declare function getDataToSignERC2771(payload: { | ||
type: ERC2771Type.CallWithSyncFee | ERC2771Type.SponsoredCall; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<SequentialPayloadToSign>; | ||
@@ -13,3 +12,3 @@ export declare function getDataToSignERC2771(payload: { | ||
type: ERC2771Type.ConcurrentCallWithSyncFee | ERC2771Type.ConcurrentSponsoredCall; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<ConcurrentPayloadToSign>; | ||
@@ -19,3 +18,3 @@ export declare function getDataToSignERC2771(payload: { | ||
type: ERC2771Type; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<PayloadToSign>; |
@@ -19,3 +19,3 @@ "use strict"; | ||
try { | ||
const { request, walletOrProvider } = payload; | ||
const { request, signerOrProvider } = payload; | ||
const { chainId } = request; | ||
@@ -26,8 +26,2 @@ const isSupported = yield (0, network_1.isNetworkSupported)({ chainId }, config); | ||
} | ||
if (walletOrProvider) { | ||
const providerChainId = yield (0, utils_1.getProviderChainId)(walletOrProvider); | ||
if (chainId !== providerChainId) { | ||
throw new Error(`Request and provider chain id mismatch. Request: [${chainId.toString()}], provider: [${providerChainId.toString()}]`); | ||
} | ||
} | ||
if ((0, utils_1.isConcurrentRequest)(request)) { | ||
@@ -38,3 +32,3 @@ const type = payload.type; | ||
type, | ||
walletOrProvider, | ||
signerOrProvider, | ||
}, config); | ||
@@ -48,3 +42,3 @@ return { | ||
const type = payload.type; | ||
const { struct, typedData } = yield (0, utils_2.populatePayloadToSign)({ request, type, walletOrProvider }, config); | ||
const { struct, typedData } = yield (0, utils_2.populatePayloadToSign)({ request, type, signerOrProvider }, config); | ||
return { | ||
@@ -51,0 +45,0 @@ struct, |
@@ -1,7 +0,6 @@ | ||
import { ethers } from "ethers"; | ||
import { Config } from "../../types"; | ||
import { Config, SignerOrProvider } from "../../types"; | ||
import { SignatureData, CallWithERC2771Request, ERC2771Type, CallWithConcurrentERC2771Request, SequentialSignatureData, ConcurrentSignatureData } from "../types"; | ||
export declare function getSignatureDataERC2771(payload: { | ||
request: CallWithERC2771Request; | ||
walletOrProvider: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider: SignerOrProvider; | ||
type: ERC2771Type.CallWithSyncFee | ERC2771Type.SponsoredCall; | ||
@@ -11,3 +10,3 @@ }, config: Config): Promise<SequentialSignatureData>; | ||
request: CallWithConcurrentERC2771Request; | ||
walletOrProvider: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider: SignerOrProvider; | ||
type: ERC2771Type.ConcurrentCallWithSyncFee | ERC2771Type.ConcurrentSponsoredCall; | ||
@@ -17,4 +16,4 @@ }, config: Config): Promise<ConcurrentSignatureData>; | ||
request: CallWithERC2771Request | CallWithConcurrentERC2771Request; | ||
walletOrProvider: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider: SignerOrProvider; | ||
type: ERC2771Type; | ||
}, config: Config): Promise<SignatureData>; |
@@ -18,6 +18,3 @@ "use strict"; | ||
try { | ||
const { request, walletOrProvider } = payload; | ||
if (!walletOrProvider.provider) { | ||
throw new Error(`Missing provider`); | ||
} | ||
const { request, signerOrProvider } = payload; | ||
if ((0, utils_1.isConcurrentRequest)(request)) { | ||
@@ -27,6 +24,6 @@ const type = payload.type; | ||
request, | ||
walletOrProvider, | ||
signerOrProvider, | ||
type, | ||
}, config); | ||
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, typedData); | ||
const signature = yield (0, utils_1.signTypedDataV4)(signerOrProvider, request.user, typedData); | ||
return { | ||
@@ -41,6 +38,6 @@ struct, | ||
request, | ||
walletOrProvider, | ||
signerOrProvider, | ||
type, | ||
}, config); | ||
const signature = yield (0, utils_1.signTypedDataV4)(walletOrProvider, request.user, typedData); | ||
const signature = yield (0, utils_1.signTypedDataV4)(signerOrProvider, request.user, typedData); | ||
return { | ||
@@ -47,0 +44,0 @@ struct, |
@@ -1,9 +0,8 @@ | ||
import { ethers } from "ethers"; | ||
import { Config, RelayRequestOptions, RelayResponse } from "../../types"; | ||
import { Config, RelayRequestOptions, RelayResponse, SignerOrProvider } from "../../types"; | ||
import { CallWithConcurrentERC2771Request, CallWithERC2771Request } from "../types"; | ||
export declare const relayWithSponsoredCallERC2771: (payload: { | ||
request: CallWithERC2771Request | CallWithConcurrentERC2771Request; | ||
walletOrProvider: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider: SignerOrProvider; | ||
sponsorApiKey: string; | ||
options?: RelayRequestOptions; | ||
}, config: Config) => Promise<RelayResponse>; |
@@ -24,6 +24,3 @@ "use strict"; | ||
try { | ||
const { request, sponsorApiKey, walletOrProvider, options } = payload; | ||
if (!walletOrProvider.provider) { | ||
throw new Error(`Missing provider`); | ||
} | ||
const { request, sponsorApiKey, signerOrProvider, options } = payload; | ||
if ((0, utils_1.isConcurrentRequest)(request)) { | ||
@@ -34,3 +31,3 @@ const isConcurrent = true; | ||
request, | ||
walletOrProvider, | ||
signerOrProvider, | ||
type, | ||
@@ -51,3 +48,3 @@ }, config); | ||
request, | ||
walletOrProvider, | ||
signerOrProvider, | ||
type, | ||
@@ -54,0 +51,0 @@ }, config); |
@@ -6,3 +6,3 @@ import { Config, SafeRequestPayload } from "../../types"; | ||
type: ERC2771Type.CallWithSyncFee | ERC2771Type.SponsoredCall; | ||
isWallet?: boolean; | ||
isSigner?: boolean; | ||
}, config: Config): SponsoredCallERC2771PayloadToSign | CallWithSyncFeeERC2771PayloadToSign; | ||
@@ -12,3 +12,3 @@ export declare function getPayloadToSign(payload: { | ||
type: ERC2771Type.ConcurrentCallWithSyncFee | ERC2771Type.ConcurrentSponsoredCall; | ||
isWallet?: boolean; | ||
isSigner?: boolean; | ||
}, config: Config): SponsoredCallConcurrentERC2771PayloadToSign | CallWithSyncFeeConcurrentERC2771PayloadToSign; |
@@ -8,7 +8,7 @@ "use strict"; | ||
function getPayloadToSign(payload, config) { | ||
const { isWallet, struct, type } = payload; | ||
const { isSigner, struct, type } = payload; | ||
const domain = (0, utils_1.getEIP712Domain)({ chainId: BigInt(struct.chainId), type }, config); | ||
switch (type) { | ||
case types_2.ERC2771Type.SponsoredCall: | ||
if (isWallet) { | ||
if (isSigner) { | ||
return { | ||
@@ -27,3 +27,3 @@ domain, | ||
case types_2.ERC2771Type.CallWithSyncFee: | ||
if (isWallet) { | ||
if (isSigner) { | ||
return { | ||
@@ -42,3 +42,3 @@ domain, | ||
case types_2.ERC2771Type.ConcurrentSponsoredCall: | ||
if (isWallet) { | ||
if (isSigner) { | ||
return { | ||
@@ -57,3 +57,3 @@ domain, | ||
case types_2.ERC2771Type.ConcurrentCallWithSyncFee: | ||
if (isWallet) { | ||
if (isSigner) { | ||
return { | ||
@@ -60,0 +60,0 @@ domain, |
@@ -1,8 +0,7 @@ | ||
import { ethers } from "ethers"; | ||
import { CallWithConcurrentERC2771Request, CallWithERC2771Request, ConcurrentPayloadToSign, ERC2771Type, SequentialPayloadToSign } from "../types"; | ||
import { Config } from "../../types"; | ||
import { Config, SignerOrProvider } from "../../types"; | ||
export declare function populatePayloadToSign(payload: { | ||
request: CallWithConcurrentERC2771Request; | ||
type: ERC2771Type.ConcurrentCallWithSyncFee | ERC2771Type.ConcurrentSponsoredCall; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<ConcurrentPayloadToSign>; | ||
@@ -12,3 +11,3 @@ export declare function populatePayloadToSign(payload: { | ||
type: ERC2771Type.CallWithSyncFee | ERC2771Type.SponsoredCall; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<SequentialPayloadToSign>; |
@@ -19,3 +19,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { request, walletOrProvider } = payload; | ||
const { request, signerOrProvider } = payload; | ||
if ((0, utils_1.isConcurrentRequest)(request)) { | ||
@@ -26,3 +26,3 @@ const type = payload.type; | ||
type, | ||
walletOrProvider, | ||
signerOrProvider, | ||
}, config); | ||
@@ -34,3 +34,3 @@ const struct = yield (0, mapRequestToStruct_1.mapRequestToStruct)(request, parametersToOverride); | ||
type, | ||
isWallet: walletOrProvider ? (0, utils_1.isWallet)(walletOrProvider) : undefined, | ||
isSigner: signerOrProvider ? (0, utils_1.isSigner)(signerOrProvider) : undefined, | ||
}, config); | ||
@@ -47,3 +47,3 @@ return { | ||
type, | ||
walletOrProvider, | ||
signerOrProvider, | ||
}, config); | ||
@@ -55,3 +55,3 @@ const struct = yield (0, mapRequestToStruct_1.mapRequestToStruct)(request, parametersToOverride); | ||
type, | ||
isWallet: walletOrProvider ? (0, utils_1.isWallet)(walletOrProvider) : undefined, | ||
isSigner: signerOrProvider ? (0, utils_1.isSigner)(signerOrProvider) : undefined, | ||
}, config); | ||
@@ -58,0 +58,0 @@ return { |
@@ -1,2 +0,2 @@ | ||
import { BytesLike } from "ethers"; | ||
import { BytesLike, ethers } from "ethers"; | ||
export declare enum RelayCall { | ||
@@ -59,1 +59,2 @@ CallWithSyncFee = 0, | ||
}; | ||
export type SignerOrProvider = ethers.BrowserProvider | ethers.Signer; |
@@ -1,2 +0,2 @@ | ||
import { ethers } from "ethers"; | ||
export declare const getProviderChainId: (walletOrProvider: ethers.BrowserProvider | ethers.Wallet) => Promise<bigint>; | ||
import { SignerOrProvider } from "../lib/types"; | ||
export declare const getProviderChainId: (signerOrProvider: SignerOrProvider) => Promise<bigint>; |
@@ -13,13 +13,13 @@ "use strict"; | ||
exports.getProviderChainId = void 0; | ||
const isWallet_1 = require("./isWallet"); | ||
const getProviderChainId = (walletOrProvider) => __awaiter(void 0, void 0, void 0, function* () { | ||
const isSigner_1 = require("./isSigner"); | ||
const getProviderChainId = (signerOrProvider) => __awaiter(void 0, void 0, void 0, function* () { | ||
let provider; | ||
if ((0, isWallet_1.isWallet)(walletOrProvider)) { | ||
if (!walletOrProvider.provider) { | ||
if ((0, isSigner_1.isSigner)(signerOrProvider)) { | ||
if (!signerOrProvider.provider) { | ||
throw new Error(`Missing provider`); | ||
} | ||
provider = walletOrProvider.provider; | ||
provider = signerOrProvider.provider; | ||
} | ||
else { | ||
provider = walletOrProvider; | ||
provider = signerOrProvider; | ||
} | ||
@@ -26,0 +26,0 @@ const { chainId } = yield provider.getNetwork(); |
@@ -1,3 +0,2 @@ | ||
import { ethers } from "ethers"; | ||
import { Config } from "../lib/types"; | ||
import { Config, SignerOrProvider } from "../lib/types"; | ||
import { ERC2771Type } from "../lib/erc2771/types"; | ||
@@ -7,3 +6,3 @@ export declare const getUserNonce: (payload: { | ||
type: ERC2771Type; | ||
walletOrProvider: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider: SignerOrProvider; | ||
}, config: Config) => Promise<bigint>; |
@@ -18,7 +18,10 @@ "use strict"; | ||
const getUserNonce = (payload, config) => __awaiter(void 0, void 0, void 0, function* () { | ||
const { account, type, walletOrProvider } = payload; | ||
const chainId = yield (0, getProviderChainId_1.getProviderChainId)(walletOrProvider); | ||
const contract = new ethers_1.ethers.Contract((0, relayAddress_1.getGelatoRelayERC2771Address)({ chainId, type }, config), constants_1.USER_NONCE_ABI, walletOrProvider); | ||
const { account, type, signerOrProvider } = payload; | ||
if (!signerOrProvider.provider) { | ||
throw new Error(`Missing provider`); | ||
} | ||
const chainId = yield (0, getProviderChainId_1.getProviderChainId)(signerOrProvider); | ||
const contract = new ethers_1.ethers.Contract((0, relayAddress_1.getGelatoRelayERC2771Address)({ chainId, type }, config), constants_1.USER_NONCE_ABI, signerOrProvider); | ||
return (yield contract.userNonce(account)); | ||
}); | ||
exports.getUserNonce = getUserNonce; |
@@ -8,3 +8,3 @@ export * from "./signTypedDataV4"; | ||
export * from "./post"; | ||
export * from "./isWallet"; | ||
export * from "./isSigner"; | ||
export * from "./relayAddress"; | ||
@@ -11,0 +11,0 @@ export * from "./isZkSync"; |
@@ -24,3 +24,3 @@ "use strict"; | ||
__exportStar(require("./post"), exports); | ||
__exportStar(require("./isWallet"), exports); | ||
__exportStar(require("./isSigner"), exports); | ||
__exportStar(require("./relayAddress"), exports); | ||
@@ -27,0 +27,0 @@ __exportStar(require("./isZkSync"), exports); |
@@ -1,8 +0,7 @@ | ||
import { ethers } from "ethers"; | ||
import { CallWithConcurrentERC2771Request, CallWithConcurrentERC2771RequestOptionalParameters, CallWithERC2771Request, CallWithERC2771RequestOptionalParameters, ERC2771Type } from "../lib/erc2771/types"; | ||
import { Config } from "../lib/types"; | ||
import { Config, SignerOrProvider } from "../lib/types"; | ||
export declare function populateOptionalUserParameters(payload: { | ||
request: CallWithConcurrentERC2771Request; | ||
type: ERC2771Type.ConcurrentCallWithSyncFee | ERC2771Type.ConcurrentSponsoredCall; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<Partial<CallWithConcurrentERC2771RequestOptionalParameters>>; | ||
@@ -12,3 +11,3 @@ export declare function populateOptionalUserParameters(payload: { | ||
type: ERC2771Type.CallWithSyncFee | ERC2771Type.SponsoredCall; | ||
walletOrProvider?: ethers.BrowserProvider | ethers.Wallet; | ||
signerOrProvider?: SignerOrProvider; | ||
}, config: Config): Promise<Partial<CallWithERC2771RequestOptionalParameters>>; |
@@ -18,2 +18,3 @@ "use strict"; | ||
const generateSalt_1 = require("./generateSalt"); | ||
const getProviderChainId_1 = require("./getProviderChainId"); | ||
function populateOptionalUserParameters(payload, config) { | ||
@@ -34,3 +35,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
else { | ||
const { type, walletOrProvider, request } = payload; | ||
const { type, signerOrProvider, request } = payload; | ||
const parametersToOverride = {}; | ||
@@ -42,9 +43,13 @@ if (!request.userDeadline) { | ||
if (request.userNonce === undefined) { | ||
if (!walletOrProvider) { | ||
if (!signerOrProvider || !signerOrProvider.provider) { | ||
throw new Error("Missing provider."); | ||
} | ||
const providerChainId = yield (0, getProviderChainId_1.getProviderChainId)(signerOrProvider); | ||
if (request.chainId !== providerChainId) { | ||
throw new Error(`Request and provider chain id mismatch. Request: [${request.chainId.toString()}], provider: [${providerChainId.toString()}]`); | ||
} | ||
parametersToOverride.userNonce = yield (0, getUserNonce_1.getUserNonce)({ | ||
account: request.user, | ||
type, | ||
walletOrProvider, | ||
signerOrProvider, | ||
}, config); | ||
@@ -51,0 +56,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { ethers } from "ethers"; | ||
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>; | ||
import { SignerOrProvider } from "../lib/types"; | ||
export declare const signTypedDataV4: (signerOrProvider: SignerOrProvider, address: string, payload: SponsoredCallERC2771PayloadToSign | CallWithSyncFeeERC2771PayloadToSign | SponsoredCallConcurrentERC2771PayloadToSign | CallWithSyncFeeConcurrentERC2771PayloadToSign) => Promise<string>; |
@@ -14,12 +14,12 @@ "use strict"; | ||
const constants_1 = require("../constants"); | ||
const isWallet_1 = require("./isWallet"); | ||
const signTypedDataV4 = (walletOrProvider, address, payload) => __awaiter(void 0, void 0, void 0, function* () { | ||
if ((0, isWallet_1.isWallet)(walletOrProvider)) { | ||
return yield walletOrProvider.signTypedData(payload.domain, payload.types, payload.message); | ||
const isSigner_1 = require("./isSigner"); | ||
const signTypedDataV4 = (signerOrProvider, address, payload) => __awaiter(void 0, void 0, void 0, function* () { | ||
if ((0, isSigner_1.isSigner)(signerOrProvider)) { | ||
return yield signerOrProvider.signTypedData(payload.domain, payload.types, payload.message); | ||
} | ||
// Magic Connect accepts payload as an object | ||
if (walletOrProvider.provider.isMagic) { | ||
return yield walletOrProvider.send(constants_1.SIGN_TYPED_DATA_V4, [address, payload]); | ||
if (signerOrProvider.provider.isMagic) { | ||
return yield signerOrProvider.send(constants_1.SIGN_TYPED_DATA_V4, [address, payload]); | ||
} | ||
const signature = yield walletOrProvider.send(constants_1.SIGN_TYPED_DATA_V4, [ | ||
const signature = yield signerOrProvider.send(constants_1.SIGN_TYPED_DATA_V4, [ | ||
address, | ||
@@ -26,0 +26,0 @@ JSON.stringify(payload), |
{ | ||
"name": "@gelatonetwork/relay-sdk", | ||
"version": "5.3.0", | ||
"version": "5.4.0", | ||
"description": "SDK to integrate with Gelato Relay", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110597
1990