@gelatonetwork/relay-sdk
Advanced tools
Comparing version 1.0.1-beta.0 to 1.0.1-beta.1
@@ -64,3 +64,3 @@ "use strict"; | ||
try { | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(request, provider); | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(types_1.PaymentType.OneBalance, request, provider); | ||
const struct = yield mapRequestToStruct(request, parametersToOverride); | ||
@@ -67,0 +67,0 @@ const signature = yield (0, utils_2.signTypedDataV4)(provider, request.user, JSON.stringify(getPayloadToSign(struct))); |
@@ -64,3 +64,3 @@ "use strict"; | ||
try { | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(request, provider); | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(types_1.PaymentType.TransferFrom, request, provider); | ||
const struct = mapRequestToStruct(request, parametersToOverride); | ||
@@ -67,0 +67,0 @@ const signature = yield (0, utils_2.signTypedDataV4)(provider, request.user, JSON.stringify(getPayloadToSign(struct))); |
@@ -47,3 +47,3 @@ "use strict"; | ||
} | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(request, signer.provider); | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(types_1.PaymentType.OneBalance, request, signer.provider); | ||
const struct = yield mapRequestToStruct(request, parametersToOverride); | ||
@@ -50,0 +50,0 @@ const domain = (0, utils_2.getEIP712Domain)(request.chainId, types_1.RelayContract.GelatoRelay); |
@@ -46,3 +46,3 @@ "use strict"; | ||
} | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(request, signer.provider); | ||
const parametersToOverride = yield (0, utils_2.populateOptionalUserParameters)(types_1.PaymentType.TransferFrom, request, signer.provider); | ||
const struct = yield mapRequestToStruct(request, parametersToOverride); | ||
@@ -49,0 +49,0 @@ const domain = (0, utils_2.getEIP712Domain)(request.chainId, types_1.RelayContract.GelatoRelayWithTransferFrom); |
import { ethers, providers } from "ethers"; | ||
export declare const getUserNonce: (chainId: number, account: string, provider: providers.Web3Provider | ethers.providers.Provider) => Promise<any>; | ||
import { PaymentType } from "../lib"; | ||
export declare const getUserNonce: (paymentType: PaymentType, chainId: number, account: string, provider: providers.Web3Provider | ethers.providers.Provider) => Promise<any>; |
@@ -15,6 +15,15 @@ "use strict"; | ||
const constants_1 = require("../constants"); | ||
const getUserNonce = (chainId, account, provider) => __awaiter(void 0, void 0, void 0, function* () { | ||
const contract = new ethers_1.ethers.Contract((0, constants_1.getRelayAddress)(chainId), constants_1.USER_NONCE_ABI, provider); | ||
const lib_1 = require("../lib"); | ||
const getUserNonce = (paymentType, chainId, account, provider) => __awaiter(void 0, void 0, void 0, function* () { | ||
const address = paymentType === lib_1.PaymentType.OneBalance | ||
? (0, constants_1.getRelayAddress)(chainId) | ||
: paymentType === lib_1.PaymentType.TransferFrom | ||
? (0, constants_1.getRelayWithTransferFromAddress)(chainId) | ||
: null; | ||
if (!address) { | ||
throw new Error(`Unsupported payment type [${paymentType}]`); | ||
} | ||
const contract = new ethers_1.ethers.Contract(address, constants_1.USER_NONCE_ABI, provider); | ||
return yield contract.userNonce(account); | ||
}); | ||
exports.getUserNonce = getUserNonce; |
import { ethers, providers } from "ethers"; | ||
import { PaymentType } from "../lib"; | ||
import { UserAuthCallWith1BalanceRequest, UserAuthCallWith1BalanceRequestOptionalParameters } from "../lib/userAuthCall/1balance/types"; | ||
@@ -6,2 +7,2 @@ import { UserAuthCallWithTransferFromRequest, UserAuthCallWithTransferFromRequestOptionalParameters } from "../lib/userAuthCall/transferFrom/types"; | ||
import { UserSponsorAuthCallWithTransferFromRequest, UserSponsorAuthCallWithTransferFromRequestOptionalParameters } from "../lib/userSponsorAuthCall/transferFrom/types"; | ||
export declare const populateOptionalUserParameters: <Request extends UserAuthCallWith1BalanceRequest | UserAuthCallWithTransferFromRequest | UserSponsorAuthCallWith1BalanceRequest | UserSponsorAuthCallWithTransferFromRequest, OptionalParameters extends UserAuthCallWith1BalanceRequestOptionalParameters | UserAuthCallWithTransferFromRequestOptionalParameters | UserSponsorAuthCallWith1BalanceRequestOptionalParameters | UserSponsorAuthCallWithTransferFromRequestOptionalParameters>(request: Request, provider: providers.Web3Provider | ethers.providers.Provider) => Promise<Partial<OptionalParameters>>; | ||
export declare const populateOptionalUserParameters: <Request extends UserAuthCallWith1BalanceRequest | UserAuthCallWithTransferFromRequest | UserSponsorAuthCallWith1BalanceRequest | UserSponsorAuthCallWithTransferFromRequest, OptionalParameters extends UserAuthCallWith1BalanceRequestOptionalParameters | UserAuthCallWithTransferFromRequestOptionalParameters | UserSponsorAuthCallWith1BalanceRequestOptionalParameters | UserSponsorAuthCallWithTransferFromRequestOptionalParameters>(paymentType: PaymentType, request: Request, provider: providers.Web3Provider | ethers.providers.Provider) => Promise<Partial<OptionalParameters>>; |
@@ -16,3 +16,3 @@ "use strict"; | ||
const getUserNonce_1 = require("./getUserNonce"); | ||
const populateOptionalUserParameters = (request, provider) => __awaiter(void 0, void 0, void 0, function* () { | ||
const populateOptionalUserParameters = (paymentType, request, provider) => __awaiter(void 0, void 0, void 0, function* () { | ||
const parametersToOverride = {}; | ||
@@ -23,3 +23,3 @@ if (!request.userDeadline) { | ||
if (!request.userNonce) { | ||
parametersToOverride.userNonce = (yield (0, getUserNonce_1.getUserNonce)(request.chainId, request.user, provider)).toNumber(); | ||
parametersToOverride.userNonce = (yield (0, getUserNonce_1.getUserNonce)(paymentType, request.chainId, request.user, provider)).toNumber(); | ||
} | ||
@@ -26,0 +26,0 @@ return parametersToOverride; |
{ | ||
"name": "@gelatonetwork/relay-sdk", | ||
"version": "1.0.1-beta.0", | ||
"version": "1.0.1-beta.1", | ||
"description": "SDK to integrate with Gelato Relay", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
62351
1176