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

@truffle/abi-utils

Package Overview
Dependencies
Maintainers
7
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@truffle/abi-utils - npm Package Compare versions

Comparing version 0.1.6 to 0.2.0

5

dist/lib/arbitrary.d.ts

@@ -10,2 +10,7 @@ import * as fc from "fast-check";

}>;
export declare const ErrorEntry: () => fc.Arbitrary<{
type: string;
name: string;
inputs: any[];
}>;
export declare const FunctionEntry: () => fc.Arbitrary<Partial<{

@@ -12,0 +17,0 @@ type: string;

22

dist/lib/arbitrary.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Abi = exports.ConstructorEntry = exports.FallbackEntry = exports.ReceiveEntry = exports.FunctionEntry = exports.EventEntry = exports.EventParameter = exports.Parameter = void 0;
exports.Abi = exports.ConstructorEntry = exports.FallbackEntry = exports.ReceiveEntry = exports.FunctionEntry = exports.ErrorEntry = exports.EventEntry = exports.EventParameter = exports.Parameter = void 0;
const fc = __importStar(require("fast-check"));

@@ -58,2 +58,12 @@ const faker_1 = __importDefault(require("faker"));

exports.EventEntry = EventEntry;
const ErrorEntry = () => fc.record({
type: fc.constant("error"),
name: ErrorName(),
inputs: fc.array(exports.Parameter(), { maxLength: 10 }).filter(inputs => {
// names that are not blank should be unique
const names = inputs.map(({ name }) => name).filter(name => name !== "");
return names.length === new Set(names).size;
})
});
exports.ErrorEntry = ErrorEntry;
const FunctionEntry = () => fc

@@ -113,3 +123,7 @@ .tuple(fc.record({

type: fc.constant("constructor"),
inputs: fc.array(exports.Parameter())
inputs: fc.array(exports.Parameter(), { maxLength: 10 }).filter(inputs => {
// names that are not blank should be unique
const names = inputs.map(({ name }) => name).filter(name => name !== "");
return names.length === new Set(names).size;
})
}), fc

@@ -130,3 +144,3 @@ .tuple(fc.oneof(fc.constant("nonpayable"), fc.constant("payable")), fc.boolean(), fc.boolean())

const Abi = () => fc
.tuple(exports.ConstructorEntry(), exports.FallbackEntry(), exports.ReceiveEntry(), fc.array(fc.oneof(exports.FunctionEntry(), exports.EventEntry())))
.tuple(exports.ConstructorEntry(), exports.FallbackEntry(), exports.ReceiveEntry(), fc.array(fc.oneof(exports.FunctionEntry(), exports.EventEntry(), exports.ErrorEntry())))
.chain(([constructor, fallback, receive, entries]) => fc.shuffledSubarray([constructor, fallback, receive, ...entries]));

@@ -211,2 +225,3 @@ exports.Abi = Abi;

"enum",
"error",
"ether",

@@ -323,2 +338,3 @@ "event",

const EventName = () => fakerToArb("{{hacker.verb}} {{hacker.noun}}", change_case_1.pascalCase);
const ErrorName = () => fakerToArb("{{hacker.noun}} {{hacker.noun}}", change_case_1.pascalCase);
const FunctionName = () => fakerToArb("{{hacker.verb}} {{hacker.noun}}");

@@ -325,0 +341,0 @@ const TypeRecord = () => Type().chain(type => type.startsWith("tuple")

@@ -43,2 +43,6 @@ "use strict";

},
ErrorEntry: {
arbitrary: Arbitrary.ErrorEntry(),
schema: withDefinitions(abiSchema.definitions.Error)
},
FunctionEntry: {

@@ -45,0 +49,0 @@ arbitrary: Arbitrary.FunctionEntry(),

2

dist/lib/normalize.js

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

if (looseEntry.type === "event" || looseEntry.type === "error") {
// nothing gets normalized for events or errorsright now
// nothing gets normalized for events or errors right now
return looseEntry;

@@ -11,0 +11,0 @@ }

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

});
jest_fast_check_1.testProp(`always includes "stateMutability" for entries that aren't events`, [Arbitrary.Abi()], looseAbi => {
jest_fast_check_1.testProp(`always includes "stateMutability" for entries that aren't events or errors`, [Arbitrary.Abi()], looseAbi => {
const abi = normalize_1.normalize(looseAbi);
expect(abi.filter(({ type }) => type !== "event")).toSatisfyAll(entry => "stateMutability" in entry);
expect(abi.filter(({ type }) => type !== "event" && type !== "error")).toSatisfyAll(entry => "stateMutability" in entry);
});

@@ -46,0 +46,0 @@ jest_fast_check_1.testProp("is idempotent", [Arbitrary.Abi()], looseAbi => {

{
"name": "@truffle/abi-utils",
"version": "0.1.6",
"version": "0.2.0",
"description": "Utilities for working with ABIs",

@@ -33,3 +33,3 @@ "keywords": [

"devDependencies": {
"@truffle/contract-schema": "^3.3.4",
"@truffle/contract-schema": "^3.4.0",
"@types/faker": "^5.1.2",

@@ -51,3 +51,3 @@ "@types/jest": "^26.0.20",

},
"gitHead": "677ca3977e5cec36357d5c5175135de01e23c2e8"
"gitHead": "4fc9f371eccf3f8518ea9437d9eb479a760eebdf"
}

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

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