Socket
Socket
Sign inDemoInstall

@metamask/utils

Package Overview
Dependencies
Maintainers
10
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/utils - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

13

CHANGELOG.md

@@ -9,2 +9,12 @@ # Changelog

## [8.1.0]
### Changed
- Make types for JSON-RPC-related structs more accurate ([#134](https://github.com/MetaMask/utils/pull/134))
- Aligning `JsonRpcParams` to be optional, yet not `undefined`.
- Updated types:
- `InferWithParams`
- `JsonRpcNotificationStruct`
- `JsonRpcParamsStruct`
- `JsonRpcRequestStruct`
## [8.0.0]

@@ -186,3 +196,4 @@ ### Changed

[Unreleased]: https://github.com/MetaMask/utils/compare/v8.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/utils/compare/v8.1.0...HEAD
[8.1.0]: https://github.com/MetaMask/utils/compare/v8.0.0...v8.1.0
[8.0.0]: https://github.com/MetaMask/utils/compare/v7.1.0...v8.0.0

@@ -189,0 +200,0 @@ [7.1.0]: https://github.com/MetaMask/utils/compare/v7.0.0...v7.1.0

14

dist/cjs/json.js

@@ -162,6 +162,6 @@ "use strict";

});
const JsonRpcParamsStruct = (0, _superstruct.optional)((0, _superstruct.union)([
const JsonRpcParamsStruct = (0, _superstruct.union)([
(0, _superstruct.record)((0, _superstruct.string)(), JsonStruct),
(0, _superstruct.array)(JsonStruct)
]));
]);
const JsonRpcRequestStruct = (0, _superstruct.object)({

@@ -171,7 +171,9 @@ id: JsonRpcIdStruct,

method: (0, _superstruct.string)(),
params: JsonRpcParamsStruct
params: (0, _superstruct.optional)(JsonRpcParamsStruct)
});
const JsonRpcNotificationStruct = (0, _superstruct.omit)(JsonRpcRequestStruct, [
'id'
]);
const JsonRpcNotificationStruct = (0, _superstruct.object)({
jsonrpc: JsonRpcVersionStruct,
method: (0, _superstruct.string)(),
params: (0, _superstruct.optional)(JsonRpcParamsStruct)
});
function isJsonRpcNotification(value) {

@@ -178,0 +180,0 @@ return (0, _superstruct.is)(value, JsonRpcNotificationStruct);

@@ -1,2 +0,2 @@

import { any, array, boolean, coerce, create, define, integer, is, lazy, literal, nullable, number, object, omit, optional, record, string, union, unknown } from 'superstruct';
import { any, array, boolean, coerce, create, define, integer, is, lazy, literal, nullable, number, object, optional, record, string, union, unknown } from 'superstruct';
import { assertStruct } from './assert';

@@ -91,6 +91,6 @@ /**

});
export const JsonRpcParamsStruct = optional(union([
export const JsonRpcParamsStruct = union([
record(string(), JsonStruct),
array(JsonStruct)
]));
]);
export const JsonRpcRequestStruct = object({

@@ -100,7 +100,9 @@ id: JsonRpcIdStruct,

method: string(),
params: JsonRpcParamsStruct
params: optional(JsonRpcParamsStruct)
});
export const JsonRpcNotificationStruct = omit(JsonRpcRequestStruct, [
'id'
]);
export const JsonRpcNotificationStruct = object({
jsonrpc: JsonRpcVersionStruct,
method: string(),
params: optional(JsonRpcParamsStruct)
});
/**

@@ -107,0 +109,0 @@ * Check if the given value is a valid {@link JsonRpcNotification} object.

@@ -97,3 +97,3 @@ import type { Infer, Struct } from 'superstruct';

jsonrpc: "2.0";
params: Json[] | Record<string, Json>;
params?: Json[] | Record<string, Json> | undefined;
}, {

@@ -103,9 +103,7 @@ id: Struct<string | number | null, null>;

method: Struct<string, null>;
params: Struct<Json[] | Record<string, Json>, null>;
params: Struct<Json[] | Record<string, Json> | undefined, null>;
}>;
export declare type InferWithParams<Type extends Struct<any>, Params extends JsonRpcParams> = Omit<Infer<Type>, 'params'> & (keyof Params extends undefined ? {
params?: Params;
} : {
params: Params;
});
export declare type InferWithParams<Type extends Struct<any>, Params extends JsonRpcParams> = Omit<Infer<Type>, 'params'> & {
params?: Exclude<Params, undefined>;
};
/**

@@ -118,9 +116,8 @@ * A JSON-RPC request object.

jsonrpc: "2.0";
params: Json[] | Record<string, Json>;
}, Omit<{
id: Struct<string | number | null, null>;
params?: Json[] | Record<string, Json> | undefined;
}, {
jsonrpc: Struct<"2.0", "2.0">;
method: Struct<string, null>;
params: Struct<Json[] | Record<string, Json>, null>;
}, "id">>;
params: Struct<Json[] | Record<string, Json> | undefined, null>;
}>;
/**

@@ -127,0 +124,0 @@ * A JSON-RPC notification object.

{
"name": "@metamask/utils",
"version": "8.0.0",
"version": "8.1.0",
"description": "Various JavaScript/TypeScript utilities of wide relevance to the MetaMask codebase",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/MetaMask/utils#readme",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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