This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2331 from trufflesuite/update-packages
Internal improvement: Org-scoped packages
- Loading branch information
Showing
84 changed files
with
399 additions
and
337 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/truffle-blockchain-utils/README.md → packages/blockchain-utils/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...ges/truffle-blockchain-utils/package.json → packages/blockchain-utils/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.