@truffle/abi-utils
Advanced tools
Comparing version
@@ -31,4 +31,4 @@ "use strict"; | ||
const fc = __importStar(require("fast-check")); | ||
const faker_1 = __importDefault(require("faker")); | ||
const change_case_1 = require("change-case"); | ||
const wordLists_1 = __importDefault(require("./wordLists")); | ||
const Parameter = () => fc | ||
@@ -326,18 +326,12 @@ .tuple(fc.record({ | ||
]); | ||
// borrowed from https://runkit.com/dubzzz/faker-to-fast-check | ||
const fakerToArb = (template, transform = change_case_1.camelCase) => { | ||
return fc | ||
.integer() | ||
.noBias() | ||
.noShrink() | ||
.map(seed => { | ||
faker_1.default.seed(seed); | ||
return transform(faker_1.default.fake(template)); | ||
}) | ||
.filter(word => !reservedWords.has(word)); | ||
const Name = (wordTypes = ["noun"], transform = change_case_1.camelCase) => { | ||
const wordArbitraries = wordTypes.map(wordType => fc.constantFrom(...wordLists_1.default[wordType])); | ||
const wordsArbitrary = fc.tuple(...wordArbitraries); | ||
const nameArbitrary = wordsArbitrary.map(words => transform(words.join(" "))); | ||
return nameArbitrary.filter(word => !reservedWords.has(word)); | ||
}; | ||
const ParameterName = () => fc.oneof({ arbitrary: fakerToArb("{{hacker.noun}}"), weight: 9 }, { arbitrary: fc.constant(""), weight: 1 }); | ||
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}}"); | ||
const ParameterName = () => fc.oneof({ arbitrary: Name(["noun"]), weight: 9 }, { arbitrary: fc.constant(""), weight: 1 }); | ||
const EventName = () => Name(["verb", "noun"], change_case_1.pascalCase); | ||
const ErrorName = () => Name(["noun", "noun"], change_case_1.pascalCase); | ||
const FunctionName = () => Name(["verb", "noun"]); | ||
const TypeRecord = () => Type().chain(type => type.startsWith("tuple") | ||
@@ -344,0 +338,0 @@ ? fc.record({ |
{ | ||
"name": "@truffle/abi-utils", | ||
"version": "0.3.1-hardhat-error.0", | ||
"version": "0.3.1", | ||
"description": "Utilities for working with ABIs", | ||
@@ -28,3 +28,2 @@ "license": "MIT", | ||
"change-case": "3.0.2", | ||
"faker": "5.5.3", | ||
"fast-check": "3.1.1", | ||
@@ -36,3 +35,2 @@ "web3-utils": "1.7.4" | ||
"@truffle/contract-schema": "^3.4.9", | ||
"@types/faker": "^5.1.2", | ||
"@types/jest": "27.4.1", | ||
@@ -56,3 +54,3 @@ "@types/jest-json-schema": "^2.1.2", | ||
}, | ||
"gitHead": "f1970ca2361849a1a7d7569d7ddc4db9657c8558" | ||
"gitHead": "14fe4a42110ef4131097dd73534cf405f1fa75a6" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
67776
0.06%3
-25%11
-8.33%973
-0.61%- Removed
- Removed