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

@near-js/utils

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@near-js/utils - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lib/constants.d.ts.map

1

lib/constants.d.ts
export declare const DEFAULT_FUNCTION_CALL_GAS: any;
//# sourceMappingURL=constants.d.ts.map

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

/** @deprecated */
export declare function logWarning(...args: any[]): void;
//# sourceMappingURL=errors.d.ts.map

7

lib/errors/errors.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logWarning = void 0;
const logger_1 = require("../logger");
/** @deprecated */
function logWarning(...args) {
if (!process.env['NEAR_NO_LOGS']) {
console.warn(...args);
}
const [message, ...optinalParams] = args;
logger_1.Logger.warn(message, ...optinalParams);
}
exports.logWarning = logWarning;
export { logWarning } from './errors';
export { ServerError, formatError, getErrorTypeFromErrorMessage, parseResultError, parseRpcError, } from './rpc_errors';
//# sourceMappingURL=index.d.ts.map

@@ -12,1 +12,2 @@ import { TypedError } from '@near-js/types';

export {};
//# sourceMappingURL=rpc_errors.d.ts.map

@@ -26,1 +26,14 @@ /**

export declare function parseNearAmount(amt?: string): string | null;
/**
* Encodes a Uint8Array or string into base58
* @param value Uint8Array or string representing a borsh encoded object
* @returns string base58 encoding of the value
*/
export declare function baseEncode(value: Uint8Array | string): string;
/**
* Decodes a base58 string into a Uint8Array
* @param value base58 encoded string
* @returns Uint8Array representing the decoded value
*/
export declare function baseDecode(value: string): Uint8Array;
//# sourceMappingURL=format.d.ts.map

@@ -6,4 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseNearAmount = exports.formatNearAmount = exports.NEAR_NOMINATION = exports.NEAR_NOMINATION_EXP = void 0;
exports.baseDecode = exports.baseEncode = exports.parseNearAmount = exports.formatNearAmount = exports.NEAR_NOMINATION = exports.NEAR_NOMINATION_EXP = void 0;
const bn_js_1 = __importDefault(require("bn.js"));
const bs58_1 = __importDefault(require("bs58"));
/**

@@ -108,1 +109,26 @@ * Exponent for calculating how many indivisible units are there in one NEAR. See {@link NEAR_NOMINATION}.

}
/**
* Encodes a Uint8Array or string into base58
* @param value Uint8Array or string representing a borsh encoded object
* @returns string base58 encoding of the value
*/
function baseEncode(value) {
if (typeof value === 'string') {
const bytes = [];
for (let c = 0; c < value.length; c++) {
bytes.push(value.charCodeAt(c));
}
value = new Uint8Array(bytes);
}
return bs58_1.default.encode(value);
}
exports.baseEncode = baseEncode;
/**
* Decodes a base58 string into a Uint8Array
* @param value base58 encoded string
* @returns Uint8Array representing the decoded value
*/
function baseDecode(value) {
return new Uint8Array(bs58_1.default.decode(value));
}
exports.baseDecode = baseDecode;

@@ -7,1 +7,3 @@ export * from './constants';

export * from './validators';
export * from './logger';
//# sourceMappingURL=index.d.ts.map

@@ -23,1 +23,2 @@ "use strict";

__exportStar(require("./validators"), exports);
__exportStar(require("./logger"), exports);

@@ -24,1 +24,2 @@ import { FinalExecutionOutcome } from '@near-js/types';

}): void;
//# sourceMappingURL=logging.d.ts.map

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

const errors_1 = require("./errors");
const SUPPRESS_LOGGING = !!process.env.NEAR_NO_LOGS;
const logger_1 = require("./logger");
/**

@@ -14,5 +14,2 @@ * Parse and print details from a query execution response

function printTxOutcomeLogsAndFailures({ contractId, outcome, }) {
if (SUPPRESS_LOGGING) {
return;
}
const flatLogs = [outcome.transaction_outcome, ...outcome.receipts_outcome]

@@ -35,3 +32,3 @@ .reduce((acc, it) => {

for (const result of flatLogs) {
console.log(`Receipt${result.receiptIds.length > 1 ? 's' : ''}: ${result.receiptIds.join(', ')}`);
logger_1.Logger.log(`Receipt${result.receiptIds.length > 1 ? 's' : ''}: ${result.receiptIds.join(', ')}`);
printTxOutcomeLogs({

@@ -43,3 +40,3 @@ contractId,

if (result.failure) {
console.warn(`\tFailure [${contractId}]: ${result.failure}`);
logger_1.Logger.warn(`\tFailure [${contractId}]: ${result.failure}`);
}

@@ -57,9 +54,6 @@ }

function printTxOutcomeLogs({ contractId, logs, prefix = '', }) {
if (SUPPRESS_LOGGING) {
return;
}
for (const log of logs) {
console.log(`${prefix}Log [${contractId}]: ${log}`);
logger_1.Logger.log(`${prefix}Log [${contractId}]: ${log}`);
}
}
exports.printTxOutcomeLogs = printTxOutcomeLogs;
import { FinalExecutionOutcome } from '@near-js/types';
/** @hidden */
export declare function getTransactionLastResult(txResult: FinalExecutionOutcome): any;
//# sourceMappingURL=provider.d.ts.map

@@ -26,1 +26,2 @@ import { CurrentEpochValidatorInfo, NextEpochValidatorInfo } from '@near-js/types';

export declare function diffEpochValidators(currentValidators: CurrentEpochValidatorInfo[], nextValidators: NextEpochValidatorInfo[]): EpochValidatorsDiff;
//# sourceMappingURL=validators.d.ts.map
{
"name": "@near-js/utils",
"version": "0.0.4",
"version": "0.0.5",
"description": "Common methods and constants for the NEAR API JavaScript client",

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

"bn.js": "5.2.1",
"depd": "^2.0.0",
"mustache": "^4.0.0",
"bs58": "4.0.0",
"depd": "2.0.0",
"mustache": "4.0.0",
"@near-js/types": "0.0.4"
},
"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"
},

@@ -22,0 +23,0 @@ "files": [

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

- [Format](src/format.ts) NEAR denomination formatting functions
- [Logging](src/logging.ts) functions for printing formatted RPC output
- [Provider](src/provider.ts) functions for parsing RPC output
- [Validators](src/validators.ts) functions for querying blockchain validators
- [Format](https://github.com/near/near-api-js/blob/master/packages/utils/src/format.ts) NEAR denomination formatting functions
- [Logging](https://github.com/near/near-api-js/blob/master/packages/utils/src/logging.ts) functions for printing formatted RPC output
- [Provider](https://github.com/near/near-api-js/blob/master/packages/utils/src/provider.ts) functions for parsing RPC output
- [Validators](https://github.com/near/near-api-js/blob/master/packages/utils/src/validators.ts) functions for querying blockchain validators

@@ -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