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

@gelatonetwork/relay-sdk

Package Overview
Dependencies
Maintainers
13
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 0.1.0 to 0.2.0

2

dist/index.d.ts
export * as utils from "./utils";
export * as RelaySDK from "./lib";
export * as RelayTransaction from "./types";
export * from "./types";

@@ -25,6 +25,9 @@ "use strict";

};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RelayTransaction = exports.RelaySDK = exports.utils = void 0;
exports.RelaySDK = exports.utils = void 0;
exports.utils = __importStar(require("./utils"));
exports.RelaySDK = __importStar(require("./lib"));
exports.RelayTransaction = __importStar(require("./types"));
__exportStar(require("./types"), exports);

@@ -1,8 +0,9 @@

import RelayTransaction from "../types/RelayTransaction.interface";
import { RelayTransaction } from "../types/";
import { BigNumber } from "ethers";
declare const sendRelayTransaction: (chainId: number, dest: string, data: string, token: string, relayerFee: BigNumber) => Promise<RelayTransaction>;
declare const isChainSupported: (chainId: number) => Promise<boolean>;
declare const getEstimatedFee: (chainId: number, paymentToken: string, gasLimit: BigNumber, isHighPriority: boolean) => Promise<BigNumber>;
declare const isOracleActive: (chainId: number) => Promise<boolean>;
declare const getPaymentTokens: (chainId: number) => Promise<string[]>;
export { isChainSupported, sendRelayTransaction, isOracleActive, getEstimatedFee, getPaymentTokens, };
declare const getEstimatedFee: (chainId: number, paymentToken: string, gasLimit: BigNumber, isHighPriority: boolean) => Promise<BigNumber>;
declare const getTaskStatus: (taskId: string) => Promise<import("@gelatonetwork/core-sdk").TransactionStatus | undefined>;
export { isChainSupported, sendRelayTransaction, isOracleActive, getPaymentTokens, getEstimatedFee, getTaskStatus, };

@@ -15,7 +15,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.getPaymentTokens = exports.getEstimatedFee = exports.isOracleActive = exports.sendRelayTransaction = exports.isChainSupported = void 0;
exports.getTaskStatus = exports.getEstimatedFee = exports.getPaymentTokens = exports.isOracleActive = exports.sendRelayTransaction = exports.isChainSupported = void 0;
const axios_1 = __importDefault(require("axios"));
const ethers_1 = require("ethers");
const constants_1 = __importDefault(require("../utils/constants"));
const { RELAY_URL } = constants_1.default;
const core_sdk_1 = require("@gelatonetwork/core-sdk");
const sendRelayTransaction = (chainId, dest, data, token, relayerFee) => __awaiter(void 0, void 0, void 0, function* () {

@@ -26,3 +24,3 @@ var _a, _b;

try {
const res = yield axios_1.default.post(`${RELAY_URL}/relays/${chainId}`, params);
const res = yield axios_1.default.post(`${core_sdk_1.RELAY_URL}/relays/${chainId}`, params);
output = res.data;

@@ -48,3 +46,3 @@ }

try {
const res = yield axios_1.default.get(`${RELAY_URL}/relays/`);
const res = yield axios_1.default.get(`${core_sdk_1.RELAY_URL}/relays/`);
result = res.data.relays;

@@ -55,49 +53,9 @@ }

});
const getEstimatedFee = (chainId, paymentToken, gasLimit, isHighPriority) => __awaiter(void 0, void 0, void 0, function* () {
const result = yield _getEstimatedFee(chainId, paymentToken, gasLimit.toString(), isHighPriority);
return result;
});
exports.getEstimatedFee = getEstimatedFee;
const _getEstimatedFee = (chainId, paymentToken, gasLimit, isHighPriority) => __awaiter(void 0, void 0, void 0, function* () {
var _c, _d;
const params = { paymentToken, gasLimit, isHighPriority };
let result;
try {
const res = yield axios_1.default.get(`${RELAY_URL}/oracles/${chainId}/estimate`, {
params,
});
result = ethers_1.BigNumber.from(res.data.estimatedFee);
}
catch (error) {
let message = `RelaySdkError: ${error.message} `;
if (axios_1.default.isAxiosError(error)) {
message += (_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
}
throw new Error(message);
}
return result;
});
const isOracleActive = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
const oracles = yield getGelatoOracles();
return oracles.includes(chainId.toString());
});
const isOracleActive = core_sdk_1.Oracle.isOracleActive;
exports.isOracleActive = isOracleActive;
const getGelatoOracles = () => __awaiter(void 0, void 0, void 0, function* () {
let result = [];
try {
const res = yield axios_1.default.get(`${RELAY_URL}/oracles/`);
result = res.data.oracles;
}
catch (error) { } // eslint-disable-line no-empty
return result;
});
const getPaymentTokens = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
let result = [];
try {
const res = yield axios_1.default.get(`${RELAY_URL}/oracles/${chainId}/paymentTokens/`);
result = res.data.paymentTokens;
}
catch (error) { } // eslint-disable-line no-empty
return result;
});
const getPaymentTokens = core_sdk_1.Oracle.getPaymentTokens;
exports.getPaymentTokens = getPaymentTokens;
const getEstimatedFee = core_sdk_1.Oracle.getEstimatedFee;
exports.getEstimatedFee = getEstimatedFee;
const getTaskStatus = core_sdk_1.Status.getTaskStatus;
exports.getTaskStatus = getTaskStatus;
export * from "./RelayTransaction.interface";
export { TransactionStatus, TaskState } from "@gelatonetwork/core-sdk";

@@ -17,2 +17,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskState = void 0;
__exportStar(require("./RelayTransaction.interface"), exports);
var core_sdk_1 = require("@gelatonetwork/core-sdk");
Object.defineProperty(exports, "TaskState", { enumerable: true, get: function () { return core_sdk_1.TaskState; } });

@@ -1,4 +0,3 @@

interface RelayTransaction {
export interface RelayTransaction {
taskId: string;
}
export default RelayTransaction;
{
"name": "@gelatonetwork/relay-sdk",
"version": "0.1.0",
"version": "0.2.0",
"description": "SDK to integrate the Gelato Multichain Relay",

@@ -32,2 +32,7 @@ "main": "dist/index.js",

"@typescript-eslint/parser": "^5.6.0",
"chai": "^4.3.6",
"chai-arrays": "^2.2.0",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^3.0.0",
"chai-subset": "^1.6.0",
"eslint": "^8.4.1",

@@ -38,3 +43,6 @@ "eslint-config-prettier": "^8.3.0",

"lint-staged": "^11.1.2",
"mocha": "^9.2.0",
"prettier": "^2.3.2",
"sinon": "^13.0.1",
"sinon-chai": "^3.7.0",
"ts-generator": "^0.1.1",

@@ -45,14 +53,7 @@ "ts-mocha": "^9.0.2",

"dependencies": {
"@gelatonetwork/core-sdk": "^0.1.0",
"axios": "^0.24.0",
"chai": "^4.3.6",
"chai-arrays": "^2.2.0",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^3.0.0",
"chai-subset": "^1.6.0",
"ethers": "^5.5.2",
"mocha": "^9.2.0",
"sinon": "^13.0.1",
"sinon-chai": "^3.7.0"
"ethers": "^5.5.2"
},
"gitHead": "ba4c7d247743f1ef3a8b638e74d7ebc891f52b0f"
"gitHead": "587072a94ff720253fa7eb2242907ae064f4693c"
}

@@ -46,8 +46,8 @@ # Gelato Multichain Relay SDK <!-- omit in toc -->

if (!isActiveOracle) {
console.log("Oracle is not active on this network");
console.log("Oracle is not active on this Oracle");
return;
}
// Estimates the transaction cost in the defined token for the inputted gasLimit
// The paymentTokenAddress is the address of the token used to pay transaction fees
// Estimate the Token cost now for the given GasLimit and it's the amount of Token
// that the function should pay back to the caller
const estimatedExecutionFeeInToken: BigNumber = await RelaySDK.getEstimatedFee(

@@ -89,2 +89,28 @@ chainId,

5. Check your transaction status:
```typescript
const status = await RelaySDK.getTaskStatus(taskId);
if (status) {
const state = (status as TransactionStatus).taskState;
switch (state) {
case TaskState.CheckPending:
console.log(`> Task pending relayer verification`);
break;
case TaskState.ExecPending:
console.log(`> Task queued for execution`);
break;
case TaskState.ExecSuccess:
console.log(`> Task successfully executed, tx hash: ${status.execution?.transactionHash}`);
break;
case TaskState.ExecReverted:
console.log(`> Task was reverted with message: ${status.lastCheck?.message}`);
break;
case TaskState.Cancelled:
console.log(`> Task was cancelled with message: ${status.lastCheck?.message}`);
break;
default:
console.log(`> Task status: ${state}`);
}
```
## Examples

@@ -91,0 +117,0 @@

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