Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2331 from trufflesuite/update-packages
Browse files Browse the repository at this point in the history
Internal improvement: Org-scoped packages
  • Loading branch information
eggplantzzz committed Aug 27, 2019
2 parents d0b177d + f0c98bb commit a5b121e
Show file tree
Hide file tree
Showing 84 changed files with 399 additions and 337 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# truffle-blockchain-utils
# @truffle/blockchain-utils
Utilities for identifying and managing blockchains
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"name": "truffle-blockchain-utils",
"name": "@truffle/blockchain-utils",
"version": "0.0.10",
"description": "Utilities for identifying and managing blockchains",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/truffle-blockchain-utils",
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/blockchain-utils",
"keywords": [
"ethereum",
"truffle",
"blockchain"
],
"author": "Tim Coulter <tim.coulter@consensys.net>",
"author": "Tim Coulter <tim@trufflesuite.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"homepage": "https://github.com/trufflesuite/truffle/tree/master/packages/truffle-blockchain-utils#readme",
"homepage": "https://github.com/trufflesuite/truffle/tree/master/packages/blockchain-utils#readme",
"gitHead": "b207efb3c1409746537293b3e0fc27350029188e",
"devDependencies": {
"mocha": "5.2.0"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "truffle-contract-schema",
"name": "@truffle/contract-schema",
"version": "3.0.13",
"description": "JSON schema for contract artifacts",
"main": "index.js",
Expand All @@ -8,20 +8,20 @@
"build": "cd spec && json2ts -i contract-object.spec.json -o ./index.d.ts",
"test": "mocha"
},
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/truffle-contract-schema",
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/contract-schema",
"keywords": [
"ethereum",
"json",
"schema",
"contract",
"artifacts"
],
"author": "Tim Coulter <tim.coulter@consensys.net>",
"author": "Tim Coulter <tim@trufflesuite.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/trufflesuite/truffle/issues"
},
"homepage": "https://github.com/trufflesuite/truffle/blob/develop/packages/truffle-contract-schema#readme",
"homepage": "https://github.com/trufflesuite/truffle/tree/master/packages/contract-schema#readme",
"dependencies": {
"ajv": "^6.10.0",
"crypto-js": "^3.1.9-1",
Expand Down
307 changes: 307 additions & 0 deletions packages/contract-schema/test/abi-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,307 @@
var Ajv = require("ajv");
var abiSchema = require("../spec/abi.spec.json");
var assert = require("assert");

describe("ABI Schema", function() {
var validate;

beforeEach("reset validator", function() {
var ajv = new Ajv({ useDefaults: true });
validate = ajv.compile(abiSchema);
});

describe("event definition", function() {
it("validates with all fields valid", function() {
var abi = [
{
type: "event",
name: "ButtonPressed",
inputs: [
{
name: "button",
type: "uint256",
indexed: true
}
],
anonymous: false
}
];

assert(validate(abi));
});

it("cannot omit type", function() {
var abi = [
{
name: "ButtonPressed",
inputs: [
{
name: "button",
type: "uint256",
indexed: true
}
],
anonymous: false
}
];

assert(!validate(abi));
});

it("cannot omit name", function() {
var abi = [
{
type: "event",
inputs: [
{
name: "button",
type: "uint256",
indexed: false
}
],
anonymous: false
}
];

assert(!validate(abi));
});

it("cannot omit inputs", function() {
var abi = [
{
type: "event",
name: "ButtonPressed",
anonymous: false
}
];

assert(!validate(abi));
});

it("cannot omit anonymous", function() {
var abi = [
{
type: "event",
name: "ButtonPressed",
inputs: [
{
name: "button",
type: "uint256",
indexed: true
}
]
}
];

assert(!validate(abi));
});
});
describe("normal function definition", function() {
it("can omit type, outputs, constant, and payable", function() {
var abi = [
{
name: "press",
inputs: [
{
name: "button",
type: "uint256"
}
],
stateMutability: "nonpayable"
}
];

assert(validate(abi));
assert.equal(abi[0].type, "function");
assert.equal(abi[0].stateMutability, "nonpayable");
assert.deepEqual(abi[0].outputs, []);
});

it("cannot omit name", function() {
var abi = [
{
type: "function",
outputs: [],
inputs: [],
stateMutability: "nonpayable"
}
];

assert(!validate(abi));
});

it("cannot omit inputs", function() {
var abi = [
{
name: "pressButton",
type: "function",
outputs: [],
stateMutability: "nonpayable"
}
];

assert(!validate(abi));
});
});

describe("constructor function definition", function() {
it("can omit constant, and payable", function() {
var abi = [
{
type: "constructor",
inputs: [
{
name: "button",
type: "uint256"
}
],
stateMutability: "nonpayable"
}
];

assert(validate(abi));
assert.equal(abi[0].type, "constructor");
assert.equal(abi[0].stateMutability, "nonpayable");
assert.deepEqual(abi[0].outputs, []);
});

it("cannot include name", function() {
var abi = [
{
name: "ButtonPresser",
type: "constructor",
inputs: [
{
name: "button",
type: "uint256"
}
],
stateMutability: "nonpayable"
}
];

assert(!validate(abi));
});

it("cannot include outputs", function() {
var abi;

abi = [
{
type: "constructor",
inputs: [
{
name: "button",
type: "uint256"
}
],
outputs: [
{
name: "amount",
type: "uint256"
}
],
stateMutability: "nonpayable"
}
];
assert(!validate(abi));

abi = [
{
type: "constructor",
inputs: [
{
name: "button",
type: "uint256"
}
],
outputs: [],
stateMutability: "nonpayable"
}
];
assert(!validate(abi));
});

it("cannot omit inputs", function() {
var abi = [
{
type: "constructor",
stateMutability: "nonpayable"
}
];

assert(!validate(abi));
});
});

describe("fallback function definition", function() {
it("can omit constant and payable", function() {
var abi = [
{
type: "fallback",
stateMutability: "nonpayable"
}
];

var valid = validate(abi);
assert(valid);
assert.equal(abi[0].stateMutability, "nonpayable");
});

it("cannot include name", function() {
var abi = [
{
type: "fallback",
name: "default",
stateMutability: "nonpayable"
}
];

assert(!validate(abi));
});

it("cannot include outputs", function() {
var abi;

abi = [
{
type: "fallback",
stateMutability: "nonpayable",
outputs: [
{
name: "amount",
type: "uint256"
}
]
}
];
assert(!validate(abi));

abi = [
{
type: "fallback",
stateMutability: "nonpayable",
outputs: []
}
];
assert(!validate(abi));
});

it("cannot include inputs", function() {
var abi = [
{
type: "fallback",
stateMutability: "payable",
inputs: [
{
name: "arg",
type: "uint256"
}
]
}
];

assert(!validate(abi));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("Schema", function() {

it("throws exception on invalid input", function() {
var invalid = {
"abi": -1
abi: -1
};

try {
Expand All @@ -22,5 +22,4 @@ describe("Schema", function() {
assert(abiErrors);
}
});

});
File renamed without changes.
File renamed without changes.

0 comments on commit a5b121e

Please sign in to comment.