-
-
Save onbjerg/b828aa3bdcc6f9ad0a316a2bfc98a304 to your computer and use it in GitHub Desktop.
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
// This is an example of how you could use the package | |
const contracts = require('@aragon/contracts') | |
// All of the contracts are exposed in the package as you would expect, | |
// so a contract named e.g. ``KeybaseRegistry`` would be accessible in | |
// ``contracts.KeybaseRegistry``. | |
// One could then interact with them through a package like ``truffle-contract`` | |
const provider = new Web3.providers.HttpProvider('http://localhost:8545') | |
const contract = require('truffle-contract') | |
const KeybaseRegistryContract = contract(contracts.KeybaseRegistry) | |
KeybaseRegistryContract.setProvider(provider) |
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
// This is the only JavaScript file in the ``@aragon/contracts`` package | |
// along with the built contracts | |
var glob = require('glob') | |
var path = require('path') | |
var basePath = './build/contracts' | |
// Load all of the JSON files in the ./build/contracts directory and expose them | |
module.exports = glob.sync( | |
path.resolve(__dirname, basePath, '*.json') | |
).reduce(function (contracts, file) { | |
var contract = require(file) | |
if (contract.contract_name) { | |
contracts[contract.contract_name] = contract | |
} | |
return contracts | |
}, {}) |
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
{ | |
"name": "@aragon/contracts", | |
"scripts": { | |
"prepublish": "truffle compile" | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment