Skip to content

Commit

Permalink
removed unfinished trezor integration
Browse files Browse the repository at this point in the history
  • Loading branch information
backslash47 committed Nov 16, 2018
1 parent 0cb3705 commit 092d53a
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 445 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cyano-wallet",
"version": "0.5.2",
"version": "0.5.3",
"private": true,
"scripts": {
"start": "node scripts/start.js",
Expand All @@ -10,7 +10,6 @@
},
"dependencies": {
"@ont-community/ontology-ts-sdk-ledger": "^1.0.8",
"@ont-community/ontology-ts-sdk-trezor": "^1.0.3",
"@types/long": "^4.0.0",
"autoprefixer": "7.1.6",
"axios": "^0.18.0",
Expand Down
19 changes: 5 additions & 14 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "Cyano wallet",
"author": "Matus Zamborsky <[email protected]>",
"description": "Cyano wallet - an Ontology wallet",
"version": "0.5.2",
"version": "0.5.3",

"browser_action": {
"default_title": "Open the wallet"
Expand All @@ -15,14 +15,8 @@
},
"content_scripts": [
{
"matches": [
"file://*/*",
"http://*/*",
"https://*/*"
],
"js": [
"/static/js/content.js"
],
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": ["/static/js/content.js"],
"run_at": "document_start",
"all_frames": true
}
Expand All @@ -32,8 +26,5 @@
"48": "favicon.png",
"128": "logo.png"
},
"permissions": [
"storage",
"http://127.0.0.1/*","webRequest","webRequestBlocking"
]
}
"permissions": ["storage", "http://127.0.0.1/*", "webRequest", "webRequestBlocking"]
}
94 changes: 47 additions & 47 deletions src/api/trezorApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,56 @@
* You should have received a copy of the GNU Lesser General Public License
* along with The Ontology Wallet&ID. If not, see <http://www.gnu.org/licenses/>.
*/
import * as Trezor from '@ont-community/ontology-ts-sdk-trezor';
// import * as Trezor from '@ont-community/ontology-ts-sdk-trezor';
import { get } from 'lodash';
import { Account, Wallet } from 'ontology-ts-sdk';
import { v4 as uuid } from 'uuid';
import { Wallet } from 'ontology-ts-sdk';

export async function isTrezorSupported() {
return await Trezor.isTrezorSupported();
return false;
// return await Trezor.isTrezorSupported();
}

export async function importTrezorKey(index: number) {
const wallet = Wallet.create(uuid());
const scrypt = wallet.scrypt;
const scryptParams = {
blockSize: scrypt.r,
cost: scrypt.n,
parallel: scrypt.p,
size: scrypt.dkLen
};

const privateKey = await Trezor.create(index);
// const publicKey = privateKey.getPublicKey();

// const identity = Identity.create(privateKey, '', uuid(), scryptParams);
// const ontId = identity.ontid;

// register the ONT ID on blockchain
// if (register) {
// const tx = OntidContract.buildRegisterOntidTx(ontId, publicKey, '0', '30000');
// tx.payer = identity.controls[0].address;
// await TransactionBuilder.signTransactionAsync(tx, privateKey);

// const protocol = ssl ? 'wss' : 'ws';
// const client = new WebsocketClient(`${protocol}://${nodeAddress}:${CONST.HTTP_WS_PORT}`, true);
// await client.sendRawTransaction(tx.serialize(), false, true);
// }

const account = Account.create(privateKey, '', uuid(), scryptParams);

// wallet.addIdentity(identity);
wallet.addAccount(account);
// wallet.setDefaultIdentity(identity.ontid);
wallet.setDefaultAccount(account.address.toBase58());

return {
wallet: wallet.toJson()
};
}
export function isTrezorKey(wallet: Wallet) {
return get(wallet.accounts[0].encryptedKey, 'type') === 'TREZOR';
}
throw new Error('Unsupported');
// const wallet = Wallet.create(uuid());
// const scrypt = wallet.scrypt;
// const scryptParams = {
// blockSize: scrypt.r,
// cost: scrypt.n,
// parallel: scrypt.p,
// size: scrypt.dkLen,
// };

// const privateKey = await Trezor.create(index);
// const publicKey = privateKey.getPublicKey();

// const identity = Identity.create(privateKey, '', uuid(), scryptParams);
// const ontId = identity.ontid;

// register the ONT ID on blockchain
// if (register) {
// const tx = OntidContract.buildRegisterOntidTx(ontId, publicKey, '0', '30000');
// tx.payer = identity.controls[0].address;

// await TransactionBuilder.signTransactionAsync(tx, privateKey);

// const protocol = ssl ? 'wss' : 'ws';
// const client = new WebsocketClient(`${protocol}://${nodeAddress}:${CONST.HTTP_WS_PORT}`, true);
// await client.sendRawTransaction(tx.serialize(), false, true);
// }

// const account = Account.create(privateKey, '', uuid(), scryptParams);

// wallet.addIdentity(identity);
// wallet.addAccount(account);
// wallet.setDefaultIdentity(identity.ontid);
// wallet.setDefaultAccount(account.address.toBase58());

// return {
// wallet: wallet.toJson(),
// };
}

export function isTrezorKey(wallet: Wallet) {
return get(wallet.accounts[0].encryptedKey, 'type') === 'TREZOR';
}
4 changes: 2 additions & 2 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import 'babel-polyfill';

import * as Ledger from '@ont-community/ontology-ts-sdk-ledger';
import * as Trezor from '@ont-community/ontology-ts-sdk-trezor';
// import * as Trezor from '@ont-community/ontology-ts-sdk-trezor';
import { Crypto } from 'ontology-ts-sdk';
import { browser } from 'webextension-polyfill-ts';
import { initBalanceProvider } from './balanceProvider';
Expand Down Expand Up @@ -59,7 +59,7 @@ browser.webRequest.onBeforeSendHeaders.addListener(
);

Crypto.registerKeyDeserializer(new Ledger.LedgerKeyDeserializer());
Crypto.registerKeyDeserializer(new Trezor.TrezorKeyDeserializer());
// Crypto.registerKeyDeserializer(new Trezor.TrezorKeyDeserializer());
Ledger.setLedgerTransport(
new Ledger.LedgerTransportIframe('https://drxwrxomfjdx5.cloudfront.net/forwarder.html', true),
);
21 changes: 10 additions & 11 deletions src/background/redux/settingsReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,32 @@
* You should have received a copy of the GNU Lesser General Public License
* along with The Ontology Wallet&ID. If not, see <http://www.gnu.org/licenses/>.
*/
import { CONST } from 'ontology-ts-sdk';
import { Reducer } from 'redux';
import { ADD_TOKEN, DEL_TOKEN, SET_SETTINGS, SettingsState } from '../../redux/settings';

const defaultState: SettingsState = { address: CONST.MAIN_NODE, ssl: false, net: 'MAIN', tokens: [] };
const defaultState: SettingsState = { address: 'dapp1.ont.io', ssl: false, net: 'MAIN', tokens: [] };
export const settingsReducer: Reducer<SettingsState> = (state = defaultState, action) => {
switch (action.type) {
case SET_SETTINGS:
return { ...state, address: action.address, ssl: action.ssl, net: action.net, tokens: action.tokens };
case ADD_TOKEN:
return {
...state,
return {
...state,
tokens: [
...state.tokens.filter(token => token.contract !== action.contract),
...state.tokens.filter((token) => token.contract !== action.contract),
{
contract: action.contract,
decimals: action.decimals,
name: action.name,
specification: action.specification,
symbol: action.symbol
}
]
symbol: action.symbol,
},
],
};
case DEL_TOKEN:
return {
...state,
tokens: state.tokens.filter(token => token.contract !== action.contract)
return {
...state,
tokens: state.tokens.filter((token) => token.contract !== action.contract),
};
default:
return state;
Expand Down
4 changes: 2 additions & 2 deletions src/popup/backgroundManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
import { History } from 'history';
import { Rpc } from 'ontology-dapi';
import { OEP4Token } from 'src/api/tokenApi';
import { browser } from 'webextension-polyfill-ts';
import { OEP4Token } from '../api/tokenApi';

class BackgroundManager {
private rpc: Rpc;
Expand All @@ -29,7 +29,7 @@ class BackgroundManager {
this.rpc = new Rpc({
addListener: browser.runtime.onMessage.addListener,
destination: 'background',
logMessages: true,
logMessages: false,
postMessage: browser.runtime.sendMessage,
source: 'popup',
});
Expand Down
12 changes: 6 additions & 6 deletions src/popup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import 'babel-polyfill';

import * as Ledger from '@ont-community/ontology-ts-sdk-ledger';
import * as Trezor from '@ont-community/ontology-ts-sdk-trezor';
// import * as Trezor from '@ont-community/ontology-ts-sdk-trezor';
import { Crypto } from 'ontology-ts-sdk';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
Expand All @@ -33,7 +33,7 @@ import * as Pages from './pages';
import { initStore } from './redux';

Crypto.registerKeyDeserializer(new Ledger.LedgerKeyDeserializer());
Crypto.registerKeyDeserializer(new Trezor.TrezorKeyDeserializer());
// Crypto.registerKeyDeserializer(new Trezor.TrezorKeyDeserializer());

/**
* Render after the redux store is connected to background script
Expand All @@ -42,7 +42,7 @@ const store = initStore();
const unsubscribe = store.subscribe(() => {
const history = initHistory(store);
initBackgroundManager(history);

const AppView: React.SFC<{}> = () => (
<Provider store={store}>
<Router history={history}>
Expand All @@ -62,7 +62,7 @@ const unsubscribe = store.subscribe(() => {
<Route path="/transfers" exact={true} component={Pages.Transfers} />

<Route path="/message-sign" exact={true} component={Pages.MessageSign} />

<Route path="/" exact={true} component={Pages.Home} />
<Route path="/new" exact={true} component={Pages.New} />
<Route path="/clear" exact={true} component={Pages.Clear} />
Expand All @@ -76,13 +76,13 @@ const unsubscribe = store.subscribe(() => {
<Route path="/ledger/new" exact={true} component={Pages.LedgerNew} />
<Route path="/ledger/confirm" exact={true} component={Pages.LedgerConfirm} />
<Route path="/ledger/signup" exact={true} component={Pages.LedgerSignup} />

<Route path="/trezor/create" exact={true} component={Pages.TrezorCreate} />
<Route path="/trezor/import" exact={true} component={Pages.TrezorImport} />
<Route path="/trezor/new" exact={true} component={Pages.TrezorNew} />
<Route path="/trezor/confirm" exact={true} component={Pages.TrezorConfirm} />
<Route path="/trezor/signup" exact={true} component={Pages.TrezorSignup} />

<Route path="/identity" exact={true} component={Pages.IdentityHome} />
<Route path="/identity/checkFailed" exact={true} component={Pages.IdentityCheckFailed} />
<Route path="/identity/clear" exact={true} component={Pages.IdentityClear} />
Expand Down
24 changes: 16 additions & 8 deletions src/popup/pages/create/createView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export const CreateView: React.SFC<Props> = (props) => (
error={t.meta.touched && t.meta.invalid}
disabled={props.loading}
/>
)} />
)}
/>
</View>
<Spacer />
<View orientation="column">
Expand All @@ -71,7 +72,8 @@ export const CreateView: React.SFC<Props> = (props) => (
error={t.meta.touched && t.meta.invalid}
disabled={props.loading}
/>
)} />
)}
/>
</View>
<Spacer />
<View orientation="column">
Expand All @@ -80,19 +82,25 @@ export const CreateView: React.SFC<Props> = (props) => (
name="neo"
render={(t) => (
<SemanticForm.Checkbox
onChange={(e, d) => t.input.onChange(d.checked)}
checked={t.input.value}
onChange={(e, d) => t.input.onChange(d.checked)}
checked={Boolean(t.input.value)}
error={t.meta.touched && t.meta.invalid}
/>
)} />
)}
/>
</View>
<Filler />
<View className="buttons">
<Button disabled={props.loading} loading={props.loading}>Sign up</Button>
<Button disabled={props.loading} onClick={props.handleCancel}>Cancel</Button>
<Button disabled={props.loading} loading={props.loading}>
Sign up
</Button>
<Button disabled={props.loading} onClick={props.handleCancel}>
Cancel
</Button>
</View>
</SemanticForm>
)} />
)}
/>
</View>
<StatusBar />
</View>
Expand Down
6 changes: 3 additions & 3 deletions src/popup/pages/deploy/deployView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as React from 'react';
import { Field, Form } from 'react-final-form';
import { Button, Form as SemanticForm } from 'semantic-ui-react';
import { AccountLogoHeader, Filler, Spacer, StatusBar, View } from '../../components';
import { gt } from '../../utils/validate';
import { gte } from '../../utils/validate';

export interface InitialValues {
name?: string;
Expand Down Expand Up @@ -153,7 +153,7 @@ export const DeployView: React.SFC<Props> = (props) => (
<label>Gas price</label>
<Field
name="gasPrice"
validate={gt(0)}
validate={gte(0)}
render={(t) => (
<SemanticForm.Input
type="number"
Expand All @@ -171,7 +171,7 @@ export const DeployView: React.SFC<Props> = (props) => (
<label>Gas limit</label>
<Field
name="gasLimit"
validate={gt(0)}
validate={gte(0)}
render={(t) => (
<SemanticForm.Input
type="number"
Expand Down
Loading

0 comments on commit 092d53a

Please sign in to comment.