-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Saddle, the Best Darn Ethereum Framework.
- Loading branch information
Showing
19 changed files
with
272 additions
and
506 deletions.
There are no files selected for viewing
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 file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 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 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,83 @@ | ||
|
||
module.exports = { | ||
// solc: "solc", // Solc command to run | ||
// solc_args: [], // Extra solc args | ||
// build_dir: ".build", // Directory to place built contracts | ||
// contracts: "contracts/*.sol", // Glob to match contract files | ||
tests: ['**/tests/*Test.js'], // Glob to match test files | ||
// networks: { // Define configuration for each network | ||
// development: { | ||
// providers: [ // How to load provider (processed in order) | ||
// {env: "PROVIDER"}, // Try to load Http provider from `PROVIDER` env variable (e.g. env PROVIDER=http://...) | ||
// {http: "http://127.0.0.1:8545"} // Fallback to localhost provider | ||
// ], | ||
// web3: { // Web3 options for immediate confirmation in development mode | ||
// gas: [ | ||
// {env: "GAS"}, | ||
// {default: "4600000"} | ||
// ], | ||
// gas_price: [ | ||
// {env: "GAS_PRICE"}, | ||
// {default: "12000000000"} | ||
// ], | ||
// options: { | ||
// transactionConfirmationBlocks: 1, | ||
// transactionBlockTimeout: 5 | ||
// } | ||
// }, | ||
// accounts: [ // How to load default account for transactions | ||
// {env: "ACCOUNT"}, // Load from `ACCOUNT` env variable (e.g. env ACCOUNT=0x...) | ||
// {unlocked: 0} // Else, try to grab first "unlocked" account from provider | ||
// ] | ||
// }, | ||
// test: { | ||
// providers: [ | ||
// {env: "PROVIDER"}, | ||
// {ganache: {}}, // In test mode, connect to a new ganache provider. Any options will be passed to ganache | ||
// ], | ||
// web3: { | ||
// gas: [ | ||
// {env: "GAS"}, | ||
// {default: "4600000"} | ||
// ], | ||
// gas_price: [ | ||
// {env: "GAS_PRICE"}, | ||
// {default: "12000000000"} | ||
// ], | ||
// options: { | ||
// transactionConfirmationBlocks: 1, | ||
// transactionBlockTimeout: 5 | ||
// } | ||
// }, | ||
// accounts: [ | ||
// {env: "ACCOUNT"}, | ||
// {unlocked: 0} | ||
// ] | ||
// }, | ||
// rinkeby: { | ||
// providers: [ | ||
// {env: "PROVIDER"}, | ||
// {file: "~/.ethereum/rinkeby-url"}, // Load from given file with contents as the URL (e.g. https://infura.io/api-key) | ||
// {http: "https://rinkeby.infura.io"} | ||
// ], | ||
// web3: { | ||
// gas: [ | ||
// {env: "GAS"}, | ||
// {default: "4600000"} | ||
// ], | ||
// gas_price: [ | ||
// {env: "GAS_PRICE"}, | ||
// {default: "12000000000"} | ||
// ], | ||
// options: { | ||
// transactionConfirmationBlocks: 1, | ||
// transactionBlockTimeout: 5 | ||
// } | ||
// }, | ||
// accounts: [ | ||
// {env: "ACCOUNT"}, | ||
// {file: "~/.ethereum/rinkeby"} // Load from given file with contents as the private key (e.g. 0x...) | ||
// ] | ||
// } | ||
// } | ||
} |
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 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,38 @@ | ||
const Web3 = require('web3'); | ||
|
||
const web3 = new Web3(); // no provider, since we won't make any calls | ||
|
||
function address(n) { | ||
return `0x${(n).toString(16).padStart(40, '0')}`; | ||
} | ||
|
||
function bytes(str) { | ||
return web3.eth.abi.encodeParameter('string', str); | ||
} | ||
|
||
function uint256(int) { | ||
return web3.eth.abi.encodeParameter('uint256', int); | ||
} | ||
|
||
function encode(timestamp, pairs) { | ||
return web3.eth.abi.encodeParameters(['uint256', 'bytes[]'], [timestamp, pairs.map(([k, v]) => { | ||
return web3.eth.abi.encodeParameters(['string', 'uint'], [k, v]) | ||
})]); | ||
} | ||
|
||
// XXX maybe want to import signing here, shared with sdk, define there or at top level? | ||
function sign(message, privateKey) { | ||
const hash = web3.utils.keccak256(message); | ||
const {r, s, v} = web3.eth.accounts.sign(hash, privateKey); | ||
const signature = web3.eth.abi.encodeParameters(['bytes32', 'bytes32', 'uint8'], [r, s, v]); | ||
const signatory = web3.eth.accounts.recover(hash, v, r, s); | ||
return {hash, message, signature, signatory}; | ||
} | ||
|
||
module.exports = { | ||
address, | ||
bytes, | ||
uint256, | ||
encode, | ||
sign | ||
}; |
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,18 @@ | ||
|
||
expect.extend({ | ||
numEquals(actual, expected) { | ||
return { | ||
pass: actual.toString() == expected.toString(), | ||
message: () => `expected ${JSON.stringify(actual)} == ${JSON.stringify(expected)}` | ||
} | ||
} | ||
}); | ||
|
||
expect.extend({ | ||
toRevert(actual, msg='revert') { | ||
return { | ||
pass: !!actual['message'] && actual.message === `VM Exception while processing transaction: ${msg}`, | ||
message: () => `expected revert, got: ${JSON.stringify(actual)}` | ||
} | ||
} | ||
}); |
Oops, something went wrong.