Socket
Socket
Sign inDemoInstall

@near-js/providers

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@near-js/providers - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

lib/exponential-backoff.d.ts.map

1

lib/exponential-backoff.d.ts
export declare function exponentialBackoff(startWaitTime: any, retryNumber: any, waitBackoff: any, getResult: any): Promise<any>;
//# sourceMappingURL=exponential-backoff.d.ts.map

@@ -12,1 +12,2 @@ export interface ConnectionInfo {

export declare function fetchJson(connectionInfoOrUrl: string | ConnectionInfo, json?: string): Promise<any>;
//# sourceMappingURL=fetch_json.d.ts.map

16

lib/fetch_json.js

@@ -40,2 +40,3 @@ "use strict";

const types_1 = require("@near-js/types");
const utils_1 = require("@near-js/utils");
const http_errors_1 = __importDefault(require("http-errors"));

@@ -46,3 +47,2 @@ const exponential_backoff_1 = require("./exponential-backoff");

const RETRY_NUMBER = 10;
const logWarning = (...args) => !process.env['NEAR_NO_LOGS'] && console.warn(...args);
function fetchJson(connectionInfoOrUrl, json) {

@@ -58,7 +58,5 @@ return __awaiter(this, void 0, void 0, function* () {

const response = yield (0, exponential_backoff_1.exponentialBackoff)(START_WAIT_TIME_MS, RETRY_NUMBER, BACKOFF_MULTIPLIER, () => __awaiter(this, void 0, void 0, function* () {
var _a;
try {
if (!global.fetch) {
global.fetch = (yield Promise.resolve().then(() => __importStar(require('./fetch')))).default;
}
const response = yield global.fetch(connectionInfo.url, {
const response = yield ((_a = global.fetch) !== null && _a !== void 0 ? _a : (yield Promise.resolve().then(() => __importStar(require('./fetch')))).default)(connectionInfo.url, {
method: json ? 'POST' : 'GET',

@@ -70,5 +68,9 @@ body: json ? json : undefined,

if (response.status === 503) {
logWarning(`Retrying HTTP request for ${connectionInfo.url} as it's not available now`);
utils_1.Logger.warn(`Retrying HTTP request for ${connectionInfo.url} as it's not available now`);
return null;
}
else if (response.status === 408) {
utils_1.Logger.warn(`Retrying HTTP request for ${connectionInfo.url} as the previous connection was unused for some time`);
return null;
}
throw (0, http_errors_1.default)(response.status, yield response.text());

@@ -80,3 +82,3 @@ }

if (error.toString().includes('FetchError') || error.toString().includes('Failed to fetch')) {
logWarning(`Retrying HTTP request for ${connectionInfo.url} because of error: ${error}`);
utils_1.Logger.warn(`Retrying HTTP request for ${connectionInfo.url} because of error: ${error}`);
return null;

@@ -83,0 +85,0 @@ }

export default function (resource: any, init: any): any;
//# sourceMappingURL=fetch.d.ts.map

@@ -5,1 +5,2 @@ export { exponentialBackoff } from './exponential-backoff';

export { fetchJson } from './fetch_json';
//# sourceMappingURL=index.d.ts.map

@@ -54,3 +54,3 @@ import { AccessKeyWithPublicKey, BlockId, BlockReference, BlockResult, BlockChangeResult, ChangeResult, ChunkId, ChunkResult, EpochValidatorInfo, FinalExecutionOutcome, GasPrice, LightClientProof, LightClientProofRequest, NextLightClientBlockRequest, NextLightClientBlockResponse, NearProtocolConfig, NodeStatusResult, QueryResponseKind } from '@near-js/types';

/**
* Query the RPC by passing an {@link providers/provider!RpcQueryRequest}
* Query the RPC by passing an {@link "@near-js/types".provider/request.RpcQueryRequest | RpcQueryRequest }
* @see [https://docs.near.org/api/rpc/contracts](https://docs.near.org/api/rpc/contracts)

@@ -66,3 +66,3 @@ *

*
* @param blockQuery {@link providers/provider!BlockReference} (passing a {@link providers/provider!BlockId} is deprecated)
* @param blockQuery {@link BlockReference} (passing a {@link BlockId} is deprecated)
*/

@@ -162,1 +162,2 @@ block(blockQuery: BlockId | BlockReference): Promise<BlockResult>;

}
//# sourceMappingURL=json-rpc-provider.d.ts.map

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

* which can be used to interact with the [NEAR RPC API](https://docs.near.org/api/rpc/introduction).
* @see {@link providers/provider | providers} for a list of request and response types
* @see {@link "@near-js/types".provider | provider} for a list of request and response types
*/

@@ -35,3 +35,2 @@ const utils_1 = require("@near-js/utils");

const transactions_1 = require("@near-js/transactions");
const borsh_1 = require("borsh");
const exponential_backoff_1 = require("./exponential-backoff");

@@ -113,3 +112,3 @@ const provider_1 = require("./provider");

return __awaiter(this, void 0, void 0, function* () {
return this.sendJsonRpc('tx', [(0, borsh_1.baseEncode)(txHash), accountId]);
return this.sendJsonRpc('tx', [(0, utils_1.baseEncode)(txHash), accountId]);
});

@@ -135,3 +134,3 @@ }

else {
return this.sendJsonRpc('EXPERIMENTAL_tx_status', [(0, borsh_1.baseEncode)(txHash), accountId]);
return this.sendJsonRpc('EXPERIMENTAL_tx_status', [(0, utils_1.baseEncode)(txHash), accountId]);
}

@@ -141,3 +140,3 @@ });

/**
* Query the RPC by passing an {@link providers/provider!RpcQueryRequest}
* Query the RPC by passing an {@link "@near-js/types".provider/request.RpcQueryRequest | RpcQueryRequest }
* @see [https://docs.near.org/api/rpc/contracts](https://docs.near.org/api/rpc/contracts)

@@ -169,3 +168,3 @@ *

*
* @param blockQuery {@link providers/provider!BlockReference} (passing a {@link providers/provider!BlockId} is deprecated)
* @param blockQuery {@link BlockReference} (passing a {@link BlockId} is deprecated)
*/

@@ -389,5 +388,3 @@ block(blockQuery) {

if (error.type === 'TimeoutError') {
if (!process.env['NEAR_NO_LOGS']) {
console.warn(`Retrying request to ${method} as it has timed out`, params);
}
utils_1.Logger.warn(`Retrying request to ${method} as it has timed out`, params);
return null;

@@ -394,0 +391,0 @@ }

@@ -30,1 +30,2 @@ /**

}
//# sourceMappingURL=provider.d.ts.map
{
"name": "@near-js/providers",
"version": "0.0.7",
"version": "0.0.8",
"description": "Library of implementations for interfacing with the NEAR blockchain",

@@ -11,16 +11,16 @@ "main": "lib/index.js",

"bn.js": "5.2.1",
"borsh": "^0.7.0",
"http-errors": "^1.7.2",
"@near-js/transactions": "0.2.1",
"borsh": "1.0.0",
"http-errors": "1.7.2",
"@near-js/transactions": "1.0.0",
"@near-js/types": "0.0.4",
"@near-js/utils": "0.0.4"
"@near-js/utils": "0.0.5"
},
"devDependencies": {
"@types/node": "^18.11.18",
"jest": "^26.0.1",
"ts-jest": "^26.5.6",
"typescript": "^4.9.4"
"@types/node": "18.11.18",
"jest": "26.0.1",
"ts-jest": "26.5.6",
"typescript": "4.9.4"
},
"optionalDependencies": {
"node-fetch": "^2.6.1"
"node-fetch": "2.6.7"
},

@@ -27,0 +27,0 @@ "files": [

@@ -7,6 +7,6 @@ # @near-js/providers

- [Provider](src/provider.ts) abstract class for interacting with NEAR RPC
- [JsonRpcProvider](src/json-rpc-provider.ts) implementation of `Provider` for [JSON-RPC](https://www.jsonrpc.org/)
- [fetch](src/fetch.ts) NodeJS `fetch` implementation
- [fetchJson](src/fetch_json.ts) low-level function for fetching and parsing RPC data
- [Provider](https://github.com/near/near-api-js/blob/master/packages/providers/src/provider.ts) abstract class for interacting with NEAR RPC
- [JsonRpcProvider](https://github.com/near/near-api-js/blob/master/packages/providers/src/json-rpc-provider.ts) implementation of `Provider` for [JSON-RPC](https://www.jsonrpc.org/)
- [fetch](https://github.com/near/near-api-js/blob/master/packages/providers/src/fetch.ts) NodeJS `fetch` implementation
- [fetchJson](https://github.com/near/near-api-js/blob/master/packages/providers/src/fetch_json.ts) low-level function for fetching and parsing RPC data

@@ -13,0 +13,0 @@ # License

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