-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fe7db42
Showing
12 changed files
with
940 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# http://editorconfig.org | ||
|
||
# This is the top-level config | ||
root = true | ||
|
||
[*] | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{js,ts}] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 |
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,10 @@ | ||
# gitignore | ||
|
||
node_modules | ||
|
||
# Only apps should have lockfiles | ||
package-lock.json | ||
/dist/* | ||
loom.umd.js | ||
/.env.test | ||
/yarn-error.log |
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 @@ | ||
/.vscode/ | ||
/dist/tests/ | ||
/dist/browser_tests.js | ||
/scripts/ | ||
/src/ | ||
.babelrc | ||
.editorconfig | ||
.prettierignore | ||
.prettierrc | ||
.travis.yml | ||
.travis_before_install.sh | ||
tsconfig.json | ||
tslint.json | ||
webpack.config.js | ||
webpack.e2e.test.config.js | ||
webpack.unit.tests.config.js | ||
yarn-error.log | ||
yarn.lock |
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,2 @@ | ||
src/proto/*.d.ts | ||
src/tests/tests_pb.d.ts |
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,7 @@ | ||
{ | ||
"parser": "typescript", | ||
"printWidth": 99, | ||
"semi": false, | ||
"singleQuote": true, | ||
"jsxBracketSameLine": true | ||
} |
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,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2018, Loom Network | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,52 @@ | ||
# Loom Truffle Provider | ||
|
||
Adapter that allows Truffle Suite to communicate with Loom DappChain | ||
|
||
## Install | ||
|
||
```bash | ||
yarn add loom-truffle-provider | ||
# or | ||
npm install loom-truffle-provider | ||
``` | ||
|
||
## Requirements | ||
|
||
``` | ||
Node >= 8 | ||
``` | ||
|
||
## Truffle | ||
|
||
Download and install [Truffle](https://github.com/trufflesuite/truffle) | ||
|
||
## Description | ||
|
||
Loom Truffle Provider allows to deploy smart contracts written on Solidity on Loom DappChain extending the Truffle use to Loom DappChain also. The following configuration is an example written on `truffle.js` (Truffle configuration) | ||
|
||
```javascript | ||
const { readFileSync } = require('fs') | ||
const TruffleLoomAdapter = require('truffle-loom-provider') | ||
|
||
const chainId = 'default' | ||
const writeUrl = 'ws://127.0.0.1:46657/websocket' | ||
const readUrl = 'ws://127.0.0.1:9999/queryws' | ||
const privateKey = readFileSync('./privateKey', 'utf-8') | ||
|
||
const truffleLoomAdapter = new TruffleLoomAdapter(chainId, writeUrl, readUrl, privateKey) | ||
|
||
module.exports = { | ||
networks: { | ||
loomdappchain: { | ||
provider: function() { | ||
return truffleLoomAdapter | ||
}, network_id: '*' | ||
} | ||
} | ||
}; | ||
``` | ||
|
||
## Notes | ||
|
||
* Make sure to have the Loom DappChain running before Truffle commands | ||
* The configuration up above requires the Truffle network option (ex.: `truffle deploy --network loomdappchain`) |
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,28 @@ | ||
{ | ||
"name": "loom-truffle-provider", | ||
"description": "Adapter that allows Truffle Suite to communicate with Loom DappChain", | ||
"author": { | ||
"name": "Loom Network", | ||
"url": "https://loomx.io" | ||
}, | ||
"version": "1.0", | ||
"license": "BSD-3-Clause", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"format": "prettier --write \"*.js\"" | ||
}, | ||
"dependencies": { | ||
"loom-js": "^1.4.4" | ||
}, | ||
"devDependencies": { | ||
"@types/google-protobuf": "^3.2.7", | ||
"@types/node": "^10.0.3", | ||
"@types/retry": "^0.10.2", | ||
"prettier": "1.12.1", | ||
"tslint": "^5.9.1", | ||
"tslint-config-prettier": "^1.12.0", | ||
"tslint-config-standard": "^7.0.0", | ||
"typescript": "^2.8.3" | ||
} | ||
} |
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,40 @@ | ||
import { | ||
CryptoUtils, Client, LoomProvider, LocalAddress, NonceTxMiddleware, SignedTxMiddleware | ||
} from 'loom-js' | ||
|
||
class TruffleLoomProvider { | ||
private _engine: LoomProvider | ||
|
||
constructor(chainId: string, writeUrl:string , readUrl: string, privateKey: string) { | ||
const _privateKey = CryptoUtils.B64ToUint8Array(privateKey) | ||
const publicKey = CryptoUtils.publicKeyFromPrivateKey(_privateKey) | ||
const client = new Client(chainId, writeUrl, readUrl) | ||
|
||
client.txMiddleware = [ | ||
new NonceTxMiddleware(publicKey, client), | ||
new SignedTxMiddleware(_privateKey) | ||
] | ||
|
||
this._engine = new LoomProvider(client) | ||
this._engine.addAccounts(LocalAddress.fromPublicKey(publicKey).toString()) | ||
this._engine.on('error', (err: any) => { | ||
console.error('Error detected within Truffle process:', err) | ||
}) | ||
} | ||
|
||
sendAsync(payload: any, callback: Function) { | ||
// Required to kill connection and not hang the process | ||
if (payload.method === 'eth_uninstallFilter') { | ||
// Five seconds after uninstall filters | ||
setTimeout(() => this._engine.disconnect(), 5000) | ||
} | ||
|
||
this._engine.sendAsync(payload, callback) | ||
} | ||
|
||
send(payload: any, callback: Function) { | ||
return this._engine.send(payload, callback) | ||
} | ||
} | ||
|
||
module.exports = TruffleLoomProvider |
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,60 @@ | ||
{ | ||
"compilerOptions": { | ||
/* Basic Options */ | ||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ | ||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | ||
"lib": ["es2015", "dom"], /* Specify library files to be included in the compilation. */ | ||
// "allowJs": true, /* Allow javascript files to be compiled. */ | ||
// "checkJs": true, /* Report errors in .js files. */ | ||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | ||
"declaration": true, /* Generates corresponding '.d.ts' file. */ | ||
"sourceMap": true, /* Generates corresponding '.map' file. */ | ||
// "outFile": "./", /* Concatenate and emit output to single file. */ | ||
"outDir": "./dist", /* Redirect output structure to the directory. */ | ||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ | ||
// "removeComments": true, /* Do not emit comments to output. */ | ||
// "noEmit": true, /* Do not emit outputs. */ | ||
// "importHelpers": true, /* Import emit helpers from 'tslib'. */ | ||
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ | ||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ | ||
|
||
/* Strict Type-Checking Options */ | ||
"strict": true, /* Enable all strict type-checking options. */ | ||
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ | ||
// "strictNullChecks": true, /* Enable strict null checks. */ | ||
// "strictFunctionTypes": true, /* Enable strict checking of function types. */ | ||
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ | ||
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ | ||
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ | ||
|
||
/* Additional Checks */ | ||
// "noUnusedLocals": true, /* Report errors on unused locals. */ | ||
// "noUnusedParameters": true, /* Report errors on unused parameters. */ | ||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||
|
||
/* Module Resolution Options */ | ||
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ | ||
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ | ||
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ | ||
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ | ||
// "typeRoots": [], /* List of folders to include type definitions from. */ | ||
// "types": [], /* Type declaration files to be included in compilation. */ | ||
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ | ||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ | ||
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ | ||
|
||
/* Source Map Options */ | ||
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ | ||
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ | ||
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ | ||
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ | ||
|
||
/* Experimental Options */ | ||
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ | ||
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ | ||
}, | ||
"include": [ | ||
"src/index.ts" | ||
] | ||
} |
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,6 @@ | ||
{ | ||
"extends": ["tslint-config-standard", "tslint-config-prettier"], | ||
"rules": { | ||
"member-ordering": false | ||
} | ||
} |
Oops, something went wrong.