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 #2350 from trufflesuite/org-scoping
Browse files Browse the repository at this point in the history
Internal improvement: Org scoping
  • Loading branch information
eggplantzzz committed Aug 30, 2019
2 parents ae8bc4f + 46d0b2c commit 5e3dd1d
Show file tree
Hide file tree
Showing 143 changed files with 329 additions and 432 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Expand Up @@ -16,5 +16,5 @@ packages/truffle/dependencies
# @truffle/debugger
packages/debugger/.tmp

# truffle-contract
packages/truffle-contract/dist
# @truffle/contract
packages/contract/dist
File renamed without changes.
File renamed without changes.
@@ -1,9 +1,9 @@
# truffle-artifactor
# @truffle/artifactor

This package saves contract artifacts into JSON files

```javascript
const Artifactor = require("truffle-artifactor");
const Artifactor = require("@truffle/artifactor");
const artifactor = new Artifactor(__dirname);
artifactor.save({/*...*/}); // => a promise saving MyContract.json to a given destination
```
Expand All @@ -16,7 +16,7 @@ artifactor.save({/*...*/}); // => a promise saving MyContract.json to a given de
* Packages up build artifacts into `.json` files, which can then be included in your project with a simple `require`.
* Manages library addresses for linked libraries.

The artifactor can be used with [truffle-contract](https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract), which provides features above and beyond `web3`:
The artifactor can be used with [@truffle/contract](https://github.com/trufflesuite/truffle/tree/develop/packages/contract), which provides features above and beyond `web3`:

* Synchronized transactions for better control flow: transactions won't be considered finished until you're guaranteed they've been mined.
* Promises. No more callback hell. Works well with `ES6` and `async/await`.
Expand All @@ -26,15 +26,15 @@ The artifactor can be used with [truffle-contract](https://github.com/trufflesui
### Install

```
$ npm install truffle-artifactor
$ npm install @truffle/artifactor
```

### Example

Here, we'll generate a `.json` files given a JSON object like [@truffle/contract-schema](https://github.com/trufflesuite/truffle/tree/develop/packages/contract-schema). This will give us a file which we can later `require` into other projects and contexts.

```javascript
const Artifactor = require("truffle-artifactor");
const Artifactor = require("@truffle/artifactor");
const artifactor = new Artifactor(__dirname);

// See truffle-schema for more info: https://github.com/trufflesuite/truffle/tree/develop/packages/contract-schema
Expand Down
File renamed without changes.
@@ -1,10 +1,10 @@
{
"private": false,
"name": "truffle-artifactor",
"name": "@truffle/artifactor",
"description": "A contract packager for Ethereum and Javascript",
"license": "MIT",
"author": "Tim Coulter",
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/truffle-artifactor",
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/artifactor",
"version": "4.0.30",
"main": "./index.js",
"scripts": {
Expand All @@ -22,7 +22,7 @@
"mocha": "5.2.0",
"require-nocache": "^1.0.0",
"temp": "^0.8.3",
"truffle-contract": "^4.0.31",
"@truffle/contract": "^4.0.31",
"web3": "1.2.1"
},
"publishConfig": {
Expand Down
@@ -1,6 +1,6 @@
const assert = require("chai").assert;
const Artifactor = require("../");
const contract = require("truffle-contract");
const contract = require("@truffle/contract");
const Schema = require("@truffle/contract-schema");
const temp = require("temp").track();
const path = require("path");
Expand Down
@@ -1,7 +1,7 @@
const assert = require("chai").assert;
const Artifactor = require("../");
const temp = require("temp").track();
const contract = require("truffle-contract");
const contract = require("@truffle/contract");
const path = require("path");
const requireNoCache = require("require-nocache")(module);

Expand Down
@@ -1,7 +1,7 @@
const assert = require("chai").assert;
const Artifactor = require("../");
const temp = require("temp").track();
const contract = require("truffle-contract");
const contract = require("@truffle/contract");
const path = require("path");
const fs = require("fs");
const requireNoCache = require("require-nocache")(module);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/box/box.js
@@ -1,7 +1,7 @@
const utils = require("./lib/utils");
const tmp = require("tmp");
const path = require("path");
const Config = require("truffle-config");
const Config = require("@truffle/config");
const ora = require("ora");
const fse = require("fs-extra");
const inquirer = require("inquirer");
Expand Down
2 changes: 1 addition & 1 deletion packages/box/package.json
Expand Up @@ -26,7 +26,7 @@
"request": "^2.85.0",
"request-promise-native": "^1.0.7",
"tmp": "0.0.33",
"truffle-config": "^1.1.20",
"@truffle/config": "^1.1.20",
"vcsurl": "^0.1.1"
},
"publishConfig": {
Expand Down
@@ -1,4 +1,4 @@
const Config = require("truffle-config");
const Config = require("@truffle/config");
const path = require("path");
const fs = require("fs");

Expand Down
4 changes: 2 additions & 2 deletions packages/compile-solidity/legacy/index.js
@@ -1,8 +1,8 @@
const debug = require("debug")("compile:legacy"); // eslint-disable-line no-unused-vars
const path = require("path");
const expect = require("@truffle/expect");
const findContracts = require("truffle-contract-sources");
const Config = require("truffle-config");
const findContracts = require("@truffle/contract-sources");
const Config = require("@truffle/config");
const Profiler = require("../profiler");
const CompilerSupplier = require("../compilerSupplier");
const { run } = require("../run");
Expand Down
4 changes: 2 additions & 2 deletions packages/compile-solidity/new/index.js
Expand Up @@ -2,8 +2,8 @@ const debug = require("debug")("compile:new"); // eslint-disable-line no-unused-
const path = require("path");
const { promisify } = require("util");
const expect = require("@truffle/expect");
const findContracts = require("truffle-contract-sources");
const Config = require("truffle-config");
const findContracts = require("@truffle/contract-sources");
const Config = require("@truffle/config");
const Profiler = require("../profiler");
const CompilerSupplier = require("../compilerSupplier");
const { run } = require("../run");
Expand Down
4 changes: 2 additions & 2 deletions packages/compile-solidity/package.json
Expand Up @@ -16,8 +16,8 @@
"require-from-string": "^2.0.2",
"semver": "^5.6.0",
"solc": "^0.5.0",
"truffle-config": "^1.1.20",
"truffle-contract-sources": "^0.1.5"
"@truffle/config": "^1.1.20",
"@truffle/contract-sources": "^0.1.5"
},
"devDependencies": {
"babel-core": "^6.26.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/compile-solidity/profiler/index.js
Expand Up @@ -4,7 +4,7 @@
const path = require("path");
const CompilerSupplier = require("../compilerSupplier");
const expect = require("@truffle/expect");
const findContracts = require("truffle-contract-sources");
const findContracts = require("@truffle/contract-sources");
const semver = require("semver");
const debug = require("debug")("compile:profiler");
const { readAndParseArtifactFiles } = require("./readAndParseArtifactFiles");
Expand Down
2 changes: 1 addition & 1 deletion packages/compile-solidity/test/test_supplier.js
Expand Up @@ -4,7 +4,7 @@ const path = require("path");
const assert = require("assert");
const Resolver = require("truffle-resolver");
const compile = require("@truffle/compile-solidity/new");
const Config = require("truffle-config");
const Config = require("@truffle/config");
const { findOne } = require("./helpers");

function waitSecond() {
Expand Down
2 changes: 1 addition & 1 deletion packages/compile-vyper/index.js
Expand Up @@ -6,7 +6,7 @@ const async = require("async");
const colors = require("colors");
const minimatch = require("minimatch");

const find_contracts = require("truffle-contract-sources");
const find_contracts = require("@truffle/contract-sources");
const Profiler = require("@truffle/compile-solidity/profiler");

const compiler = {
Expand Down
2 changes: 1 addition & 1 deletion packages/compile-vyper/package.json
Expand Up @@ -18,7 +18,7 @@
},
"devDependencies": {
"mocha": "5.2.0",
"truffle-config": "^1.1.20"
"@truffle/config": "^1.1.20"
},
"keywords": [
"compile",
Expand Down
2 changes: 1 addition & 1 deletion packages/compile-vyper/test/test_compiler.js
@@ -1,6 +1,6 @@
const path = require("path");
const assert = require("assert");
const Config = require("truffle-config");
const Config = require("@truffle/config");
const compile = require("../index");

describe("vyper compiler", function() {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,9 +1,9 @@
# truffle-config
# @truffle/config
Utility for interacting with truffle-config.js files

### Usage
```javascript
const TruffleConfig = require("truffle-config");
const TruffleConfig = require("@truffle/config");
```

#### Instantiate default TruffleConfig object
Expand Down
File renamed without changes.
@@ -1,23 +1,23 @@
{
"name": "truffle-config",
"name": "@truffle/config",
"version": "1.1.20",
"description": "Utility for interacting with truffle-config.js files",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/truffle-config",
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/config",
"keywords": [
"ethereum",
"truffle",
"config"
],
"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-config#readme",
"homepage": "https://github.com/trufflesuite/truffle/tree/master/packages/config#readme",
"dependencies": {
"@truffle/error": "^0.0.6",
"configstore": "^4.0.0",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/contract-schema/README.md
Expand Up @@ -5,11 +5,11 @@
| JSON Schema | [contract-object.spec.json](spec/contract-object.spec.json) |


[truffle-contract](https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract) uses a
[@truffle/contract](https://github.com/trufflesuite/truffle/tree/develop/packages/contract) uses a
formally specified<sup>[1](#footnote-1)</sup> JSON object format to represent
Ethereum Virtual Machine (EVM) smart contracts. This representation is intended
to facilitate the use of general purpose smart contract abstractions
(such as truffle-contract) by capturing relevant smart contract information in a
(such as @truffle/contract) by capturing relevant smart contract information in a
persistent and portable manner.

Objects following this schema represent individual smart contracts as defined
Expand Down
2 changes: 1 addition & 1 deletion packages/contract-schema/test/networks.js
@@ -1,4 +1,4 @@
var contract = require("truffle-contract");
var contract = require("@truffle/contract");

var Schema = require("../index.js");
var assert = require("assert");
Expand Down
@@ -1,2 +1,2 @@
# truffle-contract-sources
# @truffle/contract-sources
Utility for finding all contracts within a directory
@@ -1,22 +1,22 @@
{
"name": "truffle-contract-sources",
"name": "@truffle/contract-sources",
"version": "0.1.5",
"description": "Utility for finding all contracts within a directory",
"main": "index.js",
"scripts": {},
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/truffle-contract-sources",
"repository": "https://github.com/trufflesuite/truffle/tree/master/packages/contract-sources",
"keywords": [
"ethereum",
"contracts",
"find",
"filesystem"
],
"author": "Tim Coulter <tim.coulter@consensys.net>",
"author": "Tim Coulter <tim@trufflesuite.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/trufflesuite/truffle-contract-sources/issues"
"url": "https://github.com/trufflesuite/truffle/issues"
},
"homepage": "https://github.com/trufflesuite/truffle-contract-sources#readme",
"homepage": "https://github.com/trufflesuite/truffle/tree/master/packages/contract-sources#readme",
"dependencies": {
"debug": "^4.1.0",
"glob": "^7.1.2"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 15 additions & 15 deletions packages/truffle-contract/README.md → packages/contract/README.md
@@ -1,11 +1,11 @@
# truffle-contract
# @truffle/contract

Better Ethereum contract abstraction, for Node and the browser.

### Install

```
$ npm install truffle-contract
$ npm install @truffle/contract
```

### Features
Expand All @@ -17,11 +17,11 @@ $ npm install truffle-contract

### Usage

First, set up a new web3 provider instance and initialize your contract, then `require("truffle-contract")`. The input to the `contract` function is a JSON blob defined by [@truffle/contract-schema](https://github.com/trufflesuite/truffle/tree/master/packages/contract-schema). This JSON blob is structured in a way that can be passed to all truffle-related projects.
First, set up a new web3 provider instance and initialize your contract, then `require("@truffle/contract")`. The input to the `contract` function is a JSON blob defined by [@truffle/contract-schema](https://github.com/trufflesuite/truffle/tree/master/packages/contract-schema). This JSON blob is structured in a way that can be passed to all truffle-related projects.

```javascript
var provider = new Web3.providers.HttpProvider("http://localhost:8545");
var contract = require("truffle-contract");
var contract = require("@truffle/contract");

var MyContract = contract({
abi: ...,
Expand Down Expand Up @@ -59,36 +59,36 @@ or equivalently in ES6 <sup>(node.js 8 or newer)</sup>:

### Browser Usage

In your `head` element, include truffle-contract:
In your `head` element, include @truffle/contract:

```
<script type="text/javascript" src="./dist/truffle-contract.min.js"></script>
```

Alternatively, you can use the non-minified versions for easier debugging.

With this usage, `truffle-contract` will be available via the `TruffleContract` object:
With this usage, `@truffle/contract` will be available via the `TruffleContract` object:

```
var MyContract = TruffleContract(...);
```

**Note**: Web3 and its dependencies are now bundled into truffle-contract
**Note**: Web3 and its dependencies are now bundled into @truffle/contract
v4.0.2 or higher.

### Full Example

Let's use `truffle-contract` with an example contract from [Dapps For Beginners](https://dappsforbeginners.wordpress.com/tutorials/your-first-dapp/). In this case, the abstraction has been saved to a `.sol` file by [truffle-artifactor](https://github.com/trufflesuite/truffle/tree/master/packages/truffle-artifactor):
Let's use `@truffle/contract` with an example contract from [Dapps For Beginners](https://dappsforbeginners.wordpress.com/tutorials/your-first-dapp/). In this case, the abstraction has been saved to a `.sol` file by [@truffle/artifactor](https://github.com/trufflesuite/truffle/tree/master/packages/artifactor):

```javascript
// Require the package that was previosly saved by truffle-artifactor
// Require the package that was previosly saved by @truffle/artifactor
var MetaCoin = require("./path/to/MetaCoin.sol");

// Remember to set the Web3 provider (see above).
MetaCoin.setProvider(provider);

// In this scenario, two users will send MetaCoin back and forth, showing
// how truffle-contract allows for easy control flow.
// how @truffle/contract allows for easy control flow.
var account_one = "5b42bd01ff...";
var account_two = "e1fd0d4a52...";

Expand All @@ -103,9 +103,9 @@ MetaCoin.at(contract_address).then(function(instance) {
// to the account listed as account_two.
return coin.sendCoin(account_two, 3, {from: account_one});
}).then(function(result) {
// This code block will not be executed until truffle-contract has verified
// This code block will not be executed until @truffle/contract has verified
// the transaction has been processed and it is included in a mined block.
// truffle-contract will error if the transaction hasn't been processed in 120 seconds.
// @truffle/contract will error if the transaction hasn't been processed in 120 seconds.

// Since we're using promises, we can return a promise for a call that will
// check account two's balance.
Expand Down Expand Up @@ -146,7 +146,7 @@ This function creates a new instance of the contract abstraction representing th

#### `MyContract.deployed()`

Creates an instance of the contract abstraction representing the contract at its deployed address. The deployed address is a special value given to truffle-contract that, when set, saves the address internally so that the deployed address can be inferred from the given Ethereum network being used. This allows you to write code referring to a specific deployed contract without having to manage those addresses yourself. Like `at()`, `deployed()` is thenable, and will resolve to a contract abstraction instance representing the deployed contract after ensuring that code exists at that location and that that address exists on the network being used.
Creates an instance of the contract abstraction representing the contract at its deployed address. The deployed address is a special value given to @truffle/contract that, when set, saves the address internally so that the deployed address can be inferred from the given Ethereum network being used. This allows you to write code referring to a specific deployed contract without having to manage those addresses yourself. Like `at()`, `deployed()` is thenable, and will resolve to a contract abstraction instance representing the deployed contract after ensuring that code exists at that location and that that address exists on the network being used.

#### `MyContract.link(instance)`

Expand Down Expand Up @@ -304,7 +304,7 @@ instance.getValue.call().then(function(val) {
});
```

Even more helpful, however is we *don't even need* to use `.call` when a function is marked as `view` or `pure`, because `truffle-contract` will automatically know that that function can only be interacted with via a call:
Even more helpful, however is we *don't even need* to use `.call` when a function is marked as `view` or `pure`, because `@truffle/contract` will automatically know that that function can only be interacted with via a call:

```javascript
instance.getValue().then(function(val) {
Expand Down Expand Up @@ -357,4 +357,4 @@ instance.setValue.estimateGas(5).then(function(result) {

# Testing

This package is the result of breaking up EtherPudding into multiple modules. Tests currently reside within [truffle-artifactor](https://github.com/trufflesuite/truffle/tree/master/packages/truffle-artifactor) but will soon move here.
This package is the result of breaking up EtherPudding into multiple modules. Tests currently reside within [@truffle/artifactor](https://github.com/trufflesuite/truffle/tree/master/packages/artifactor) but will soon move here.
File renamed without changes.
File renamed without changes.

0 comments on commit 5e3dd1d

Please sign in to comment.