Socket
Socket
Sign inDemoInstall

@truffle/contract-schema

Package Overview
Dependencies
Maintainers
7
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@truffle/contract-schema - npm Package Compare versions

Comparing version 3.4.0-abi-utils.0 to 3.4.0

39

index.js

@@ -71,3 +71,3 @@ var pkgVersion = require("./package.json").version;

value = JSON.parse(value);
} catch (e) {
} catch (_) {
value = undefined;

@@ -111,5 +111,27 @@ }

sourceMap: {
transform: function (value) {
if (typeof value === "string") {
try {
return JSON.parse(value);
} catch (_) {
return value;
}
} else {
return value;
}
},
sources: ["sourceMap", "srcmap", "evm.bytecode.sourceMap"]
},
deployedSourceMap: {
transform: function (value) {
if (typeof value === "string") {
try {
return JSON.parse(value);
} catch (_) {
return value;
}
} else {
return value;
}
},
sources: [

@@ -126,9 +148,6 @@ "deployedSourceMap",

transform: function (value, obj) {
var schemaVersion = obj.schemaVersion || "0.0.0";
// legacyAST introduced in v2.0.0
if (schemaVersion[0] < 2) {
if (value) {
return value;
} else {
return obj.ast;
} else {
return value;
}

@@ -182,3 +201,4 @@ }

devdoc: {},
userdoc: {}
userdoc: {},
db: {}
};

@@ -202,3 +222,3 @@

return transform(obj[key]);
} catch (e) {
} catch (_) {
return undefined;

@@ -252,3 +272,2 @@ }

data,
schema, // eslint-disable-line no-unused-vars
parentSchema

@@ -255,0 +274,0 @@ }) =>

@@ -11,3 +11,3 @@ {

},
"version": "3.4.0-abi-utils.0",
"version": "3.4.0",
"main": "index.js",

@@ -26,3 +26,3 @@ "directories": {

"crypto-js": "^3.1.9-1",
"debug": "^4.1.0"
"debug": "^4.3.1"
},

@@ -32,3 +32,3 @@ "devDependencies": {

"mocha": "8.1.2",
"solc": "0.5.16"
"solc": "0.6.0"
},

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

},
"gitHead": "d23827f83f3fa232fb0a934a7d0406239e1c3c7c"
"gitHead": "4fc9f371eccf3f8518ea9437d9eb479a760eebdf"
}

@@ -9,2 +9,3 @@ {

{ "$ref": "#/definitions/Event" },
{ "$ref": "#/definitions/Error" },
{ "$ref": "#/definitions/ConstructorFunction" },

@@ -154,2 +155,19 @@ { "$ref": "#/definitions/FallbackFunction" },

"Error": {
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["error"]
},
"name": { "$ref": "#/definitions/Name" },
"inputs": {
"type": "array",
"items": { "$ref": "#/definitions/Parameter" }
}
},
"required": ["type", "name", "inputs"],
"additionalProperties": false
},
"Parameter": {

@@ -156,0 +174,0 @@ "type": "object",

@@ -93,2 +93,16 @@ {

"$ref": "#/definitions/GeneratedSources"
},
"db": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9]+$": {
"type": "object",
"description": "Reference to @truffle/db canonical ID object for correlation purposes",
"properties": {
"id": {
"type": "string"
}
}
}
}
}

@@ -95,0 +109,0 @@ },

@@ -22,2 +22,9 @@ /* tslint:disable */

}
| {
type: "error";
name: string;
inputs: {
[k: string]: any;
}[];
}
| (

@@ -112,2 +119,14 @@ | {

deployedGeneratedSources?: GeneratedSources;
db?: {
/**
* Reference to @truffle/db canonical ID object for correlation purposes
*
* This interface was referenced by `undefined`'s JSON-Schema definition
* via the `patternProperty` "^[a-zA-Z0-9]+$".
*/
[k: string]: {
id?: string;
[k: string]: any;
};
};
/**

@@ -164,2 +183,14 @@ * This interface was referenced by `ContractObject`'s JSON-Schema definition

};
db?: {
/**
* Reference to @truffle/db canonical ID object for correlation purposes
*
* This interface was referenced by `undefined`'s JSON-Schema definition
* via the `patternProperty` "^[a-zA-Z0-9]+$".
*/
[k: string]: {
id?: string;
[k: string]: any;
};
};
}

@@ -166,0 +197,0 @@ export interface NatSpec {

@@ -23,2 +23,16 @@ {

"additionalProperties": false
},
"db": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9]+$": {
"type": "object",
"description": "Reference to @truffle/db canonical ID object for correlation purposes",
"properties": {
"id": {
"type": "string"
}
}
}
}
}

@@ -25,0 +39,0 @@ },

@@ -99,2 +99,77 @@ var Ajv = require("ajv");

});
describe("error definition", function() {
it("validates with all fields valid", function() {
var abi = [
{
type: "error",
name: "InsufficientBalance",
inputs: [
{
name: "needed",
type: "uint256",
},
{
name: "actual",
type: "uint256",
}
]
}
];
assert(validate(abi));
});
it("cannot omit type", function() {
var abi = [
{
name: "InsufficientBalance",
inputs: [
{
name: "needed",
type: "uint256",
},
{
name: "actual",
type: "uint256",
}
]
}
];
assert(!validate(abi));
});
it("cannot omit name", function() {
var abi = [
{
type: "error",
inputs: [
{
name: "needed",
type: "uint256",
},
{
name: "actual",
type: "uint256",
}
]
}
];
assert(!validate(abi));
});
it("cannot omit inputs", function() {
var abi = [
{
type: "error",
name: "InsufficientBalance"
}
];
assert(!validate(abi));
});
});
describe("normal function definition", function() {

@@ -101,0 +176,0 @@ it("can omit type, outputs, constant, and payable", function() {

@@ -1,8 +0,8 @@

var assert = require("assert");
var solc = require("solc");
var Schema = require("../");
var debug = require("debug")("test:solc"); // eslint-disable-line no-unused-vars
const assert = require("assert");
const solc = require("solc");
const Schema = require("../");
const debug = require("debug")("test:solc");
describe("solc", function() {
var exampleSolidity = `pragma solidity ^0.5.0;
describe("solc", function () {
const exampleSolidity = `pragma solidity ^0.6.0;

@@ -22,6 +22,6 @@ contract A {

it("processes solc standard JSON output correctly", function(done) {
it("processes solc standard JSON output correctly", function () {
this.timeout(5000);
var solcIn = JSON.stringify({
const solcIn = JSON.stringify({
language: "Solidity",

@@ -45,3 +45,4 @@ sources: {

"userdoc"
]
],
"": ["ast", "legacyAST"]
}

@@ -51,10 +52,15 @@ }

});
var solcOut = JSON.parse(solc.compile(solcIn));
const solcOut = JSON.parse(solc.compile(solcIn));
// contracts now grouped by solidity source file
var rawA = solcOut.contracts["A.sol"].A;
debug("solcOut: %O", solcOut);
var A = Schema.normalize(rawA);
const rawA = Object.assign(
{},
solcOut.contracts["A.sol"].A, // contracts now grouped by solidity source file
solcOut.sources["A.sol"]
);
var expected = {
const A = Schema.normalize(rawA);
const expected = {
abi: rawA.abi,

@@ -70,5 +76,5 @@ metadata: rawA.metadata,

Object.keys(expected).forEach(function(key) {
var expectedValue = expected[key];
var actualValue = A[key];
Object.keys(expected).forEach(function (key) {
const expectedValue = expected[key];
const actualValue = A[key];

@@ -88,6 +94,9 @@ assert.deepEqual(

//check that ast and legacyAST have the correct form
assert.equal(A.ast.nodeType, "SourceUnit");
assert.equal(A.legacyAST.name, "SourceUnit");
// throws error if invalid
Schema.validate(A);
done();
});
});
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