@gelatonetwork/relay-sdk
Advanced tools
Comparing version 5.4.0 to 5.5.0
@@ -124,2 +124,22 @@ import { CallWithSyncFeeRequest } from "./lib/callWithSyncFee/types"; | ||
getTaskStatus: (taskId: string) => Promise<TransactionStatusResponse | undefined>; | ||
/** | ||
* @param {callback} handler - Callback function to be called on every task status update | ||
* | ||
*/ | ||
onTaskStatusUpdate: (handler: (taskStatus: TransactionStatusResponse) => void) => void; | ||
/** | ||
* @param {callback} handler - Callback function to be unregistered from task status updates | ||
* | ||
*/ | ||
offTaskStatusUpdate: (handler: (taskStatus: TransactionStatusResponse) => void) => void; | ||
/** | ||
* @param {callback} handler - Callback function to be called on error | ||
* | ||
*/ | ||
onError: (handler: (error: Error) => void) => void; | ||
/** | ||
* @param {callback} handler - Callback function to be unregistered as an error handler | ||
* | ||
*/ | ||
offError: (handler: (error: Error) => void) => void; | ||
} |
@@ -25,2 +25,11 @@ "use strict"; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
@@ -37,3 +46,3 @@ if (kind === "m") throw new TypeError("Private method is not writable"); | ||
}; | ||
var _GelatoRelay_config; | ||
var _GelatoRelay_config, _GelatoRelay_websocketHandler; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -45,5 +54,7 @@ exports.GelatoRelay = exports.ERC2771Type = void 0; | ||
const constants_1 = require("./constants"); | ||
const index_js_1 = require("./utils/index.js"); | ||
class GelatoRelay { | ||
constructor(config) { | ||
_GelatoRelay_config.set(this, void 0); | ||
_GelatoRelay_websocketHandler.set(this, void 0); | ||
/** | ||
@@ -57,4 +68,6 @@ * @param {Config} config Configuration | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s; | ||
const url = (_a = config === null || config === void 0 ? void 0 : config.url) !== null && _a !== void 0 ? _a : constants_1.GELATO_RELAY_URL; | ||
return { | ||
url: (_a = config === null || config === void 0 ? void 0 : config.url) !== null && _a !== void 0 ? _a : constants_1.GELATO_RELAY_URL, | ||
url, | ||
websocketUrl: url.replace(/^http/, "ws"), | ||
contract: { | ||
@@ -79,3 +92,9 @@ relayERC2771: (_c = (_b = config === null || config === void 0 ? void 0 : config.contract) === null || _b === void 0 ? void 0 : _b.relayERC2771) !== null && _c !== void 0 ? _c : constants_1.GELATO_RELAY_ERC2771_ADDRESS, | ||
*/ | ||
this.callWithSyncFee = (request, options, sponsorApiKey) => library.relayWithSyncFee({ request, sponsorApiKey, options }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.callWithSyncFee = (request, options, sponsorApiKey) => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield library.relayWithSyncFee({ request, sponsorApiKey, options }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
if (__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").hasHandlers()) { | ||
yield __classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").subscribe(response.taskId); | ||
} | ||
return response; | ||
}); | ||
/** | ||
@@ -89,8 +108,14 @@ * @param {CallWithSyncFeeERC2771Request | CallWithSyncFeeConcurrentERC2771Request} request - Call with sync fee: Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors | ||
*/ | ||
this.callWithSyncFeeERC2771 = (request, signerOrProvider, options, sponsorApiKey) => library.relayWithCallWithSyncFeeERC2771({ | ||
request, | ||
signerOrProvider, | ||
sponsorApiKey, | ||
options, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.callWithSyncFeeERC2771 = (request, signerOrProvider, options, sponsorApiKey) => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield library.relayWithCallWithSyncFeeERC2771({ | ||
request, | ||
signerOrProvider, | ||
sponsorApiKey, | ||
options, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
if (__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").hasHandlers()) { | ||
yield __classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").subscribe(response.taskId); | ||
} | ||
return response; | ||
}); | ||
/** | ||
@@ -103,3 +128,9 @@ * @param {SponsoredCallRequest} request SponsoredCallRequest to be relayed by the Gelato Executors. | ||
*/ | ||
this.sponsoredCall = (request, sponsorApiKey, options) => library.relayWithSponsoredCall({ request, sponsorApiKey, options }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.sponsoredCall = (request, sponsorApiKey, options) => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield library.relayWithSponsoredCall({ request, sponsorApiKey, options }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
if (__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").hasHandlers()) { | ||
yield __classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").subscribe(response.taskId); | ||
} | ||
return response; | ||
}); | ||
/** | ||
@@ -113,8 +144,14 @@ * @param {CallWithERC2771Request | CallWithConcurrentERC2771Request} request - Sponsored: Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors | ||
*/ | ||
this.sponsoredCallERC2771 = (request, signerOrProvider, sponsorApiKey, options) => library.relayWithSponsoredCallERC2771({ | ||
request, | ||
signerOrProvider, | ||
sponsorApiKey, | ||
options, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.sponsoredCallERC2771 = (request, signerOrProvider, sponsorApiKey, options) => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield library.relayWithSponsoredCallERC2771({ | ||
request, | ||
signerOrProvider, | ||
sponsorApiKey, | ||
options, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
if (__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").hasHandlers()) { | ||
yield __classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").subscribe(response.taskId); | ||
} | ||
return response; | ||
}); | ||
/** | ||
@@ -144,8 +181,14 @@ * @param {CallWithERC2771Request | CallWithConcurrentERC2771Request} request - Sequential ERC2771 or Concurrent ERC2771 request to be relayed by Gelato Executors | ||
*/ | ||
this.sponsoredCallERC2771WithSignature = (struct, signature, sponsorApiKey, options) => library.sponsoredCallERC2771WithSignature({ | ||
struct, | ||
signature, | ||
sponsorApiKey, | ||
options, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.sponsoredCallERC2771WithSignature = (struct, signature, sponsorApiKey, options) => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield library.sponsoredCallERC2771WithSignature({ | ||
struct, | ||
signature, | ||
sponsorApiKey, | ||
options, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
if (__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").hasHandlers()) { | ||
yield __classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").subscribe(response.taskId); | ||
} | ||
return response; | ||
}); | ||
/** | ||
@@ -160,9 +203,15 @@ * @param {SignatureData["struct"]} struct - Struct that can be obtained from getSignatureDataERC2771 | ||
*/ | ||
this.callWithSyncFeeERC2771WithSignature = (struct, syncFeeParams, signature, options, sponsorApiKey) => library.callWithSyncFeeERC2771WithSignature({ | ||
struct, | ||
syncFeeParams, | ||
signature, | ||
options, | ||
sponsorApiKey, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
this.callWithSyncFeeERC2771WithSignature = (struct, syncFeeParams, signature, options, sponsorApiKey) => __awaiter(this, void 0, void 0, function* () { | ||
const response = yield library.callWithSyncFeeERC2771WithSignature({ | ||
struct, | ||
syncFeeParams, | ||
signature, | ||
options, | ||
sponsorApiKey, | ||
}, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
if (__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").hasHandlers()) { | ||
yield __classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").subscribe(response.taskId); | ||
} | ||
return response; | ||
}); | ||
/** | ||
@@ -208,6 +257,35 @@ * @param {bigint} chainId - Chain Id | ||
this.getTaskStatus = (taskId) => library.getTaskStatus({ taskId }, __classPrivateFieldGet(this, _GelatoRelay_config, "f")); | ||
/** | ||
* @param {callback} handler - Callback function to be called on every task status update | ||
* | ||
*/ | ||
this.onTaskStatusUpdate = (handler) => { | ||
__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").onUpdate(handler); | ||
}; | ||
/** | ||
* @param {callback} handler - Callback function to be unregistered from task status updates | ||
* | ||
*/ | ||
this.offTaskStatusUpdate = (handler) => { | ||
__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").offUpdate(handler); | ||
}; | ||
/** | ||
* @param {callback} handler - Callback function to be called on error | ||
* | ||
*/ | ||
this.onError = (handler) => { | ||
__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").onError(handler); | ||
}; | ||
/** | ||
* @param {callback} handler - Callback function to be unregistered as an error handler | ||
* | ||
*/ | ||
this.offError = (handler) => { | ||
__classPrivateFieldGet(this, _GelatoRelay_websocketHandler, "f").offError(handler); | ||
}; | ||
__classPrivateFieldSet(this, _GelatoRelay_config, this._getConfiguration(config), "f"); | ||
__classPrivateFieldSet(this, _GelatoRelay_websocketHandler, new index_js_1.WebsocketHandler(__classPrivateFieldGet(this, _GelatoRelay_config, "f").websocketUrl), "f"); | ||
} | ||
} | ||
exports.GelatoRelay = GelatoRelay; | ||
_GelatoRelay_config = new WeakMap(); | ||
_GelatoRelay_config = new WeakMap(), _GelatoRelay_websocketHandler = new WeakMap(); |
@@ -11,13 +11,12 @@ export type TransactionStatusResponse = { | ||
executionDate?: string; | ||
gasUsed?: string; | ||
effectiveGasPrice?: string; | ||
}; | ||
declare enum TaskState { | ||
export declare enum TaskState { | ||
CheckPending = "CheckPending", | ||
ExecPending = "ExecPending", | ||
WaitingForConfirmation = "WaitingForConfirmation", | ||
ExecSuccess = "ExecSuccess", | ||
ExecReverted = "ExecReverted", | ||
WaitingForConfirmation = "WaitingForConfirmation", | ||
Blacklisted = "Blacklisted", | ||
Cancelled = "Cancelled", | ||
NotFound = "NotFound" | ||
Cancelled = "Cancelled" | ||
} | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TaskState = void 0; | ||
var TaskState; | ||
@@ -7,8 +8,6 @@ (function (TaskState) { | ||
TaskState["ExecPending"] = "ExecPending"; | ||
TaskState["WaitingForConfirmation"] = "WaitingForConfirmation"; | ||
TaskState["ExecSuccess"] = "ExecSuccess"; | ||
TaskState["ExecReverted"] = "ExecReverted"; | ||
TaskState["WaitingForConfirmation"] = "WaitingForConfirmation"; | ||
TaskState["Blacklisted"] = "Blacklisted"; | ||
TaskState["Cancelled"] = "Cancelled"; | ||
TaskState["NotFound"] = "NotFound"; | ||
})(TaskState || (TaskState = {})); | ||
})(TaskState = exports.TaskState || (exports.TaskState = {})); |
@@ -45,2 +45,3 @@ import { BytesLike, ethers } from "ethers"; | ||
url: string; | ||
websocketUrl: string; | ||
contract: { | ||
@@ -47,0 +48,0 @@ relayERC2771: string; |
@@ -16,1 +16,3 @@ export * from "./signTypedDataV4"; | ||
export * from "./generateSalt"; | ||
export * from "./isFinalTaskState"; | ||
export * from "./websocketHandler"; |
@@ -32,1 +32,3 @@ "use strict"; | ||
__exportStar(require("./generateSalt"), exports); | ||
__exportStar(require("./isFinalTaskState"), exports); | ||
__exportStar(require("./websocketHandler"), exports); |
{ | ||
"name": "@gelatonetwork/relay-sdk", | ||
"version": "5.4.0", | ||
"version": "5.5.0", | ||
"description": "SDK to integrate with Gelato Relay", | ||
@@ -42,3 +42,5 @@ "main": "dist/index.js", | ||
"axios": "0.27.2", | ||
"ethers": "6.7.0" | ||
"ethers": "6.7.0", | ||
"isomorphic-ws": "^5.0.0", | ||
"ws": "^8.5.0" | ||
}, | ||
@@ -45,0 +47,0 @@ "lint-staged": { |
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
128638
90
2351
4
+ Addedisomorphic-ws@^5.0.0
+ Addedws@^8.5.0
+ Addedisomorphic-ws@5.0.0(transitive)
+ Addedws@8.18.0(transitive)