mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-29 04:04:02 +03:00
btc: more frontend template stuff
This commit is contained in:
parent
fc1dbe4f30
commit
d32e78799f
31
pkg/arvo/app/btc-wallet/index.html
Normal file
31
pkg/arvo/app/btc-wallet/index.html
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Wallet</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1, shrink-to-fit=no,maximum-scale=1"/>
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
|
<meta name="apple-touch-fullscreen" content="yes" />
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
|
||||||
|
<!--
|
||||||
|
<link rel="apple-touch-icon" href="/~btc/img/touch_icon.png">
|
||||||
|
<link rel="icon" type="image/png" href="/~btc/img/Favicon.png">
|
||||||
|
-->
|
||||||
|
<link rel="manifest"
|
||||||
|
href='data:application/manifest+json,{
|
||||||
|
"name": "Wallet",
|
||||||
|
"short_name": "Wallet",
|
||||||
|
"description": "A%20bitcoin%20wallet%20for%20urbit",
|
||||||
|
"display": "standalone",
|
||||||
|
"background_color": "%23FFFFFF",
|
||||||
|
"theme_color": "%23000000"}' />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<div id="portal-root"></div>
|
||||||
|
<script src="/~landscape/js/channel.js"></script>
|
||||||
|
<script src="/~landscape/js/session.js"></script>
|
||||||
|
<script src="/~btc/js/bundle/index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
9885
pkg/btc-wallet/package-lock.json
generated
Normal file
9885
pkg/btc-wallet/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
71
pkg/btc-wallet/package.json
Normal file
71
pkg/btc-wallet/package.json
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
{
|
||||||
|
"name": "urbit-bitcoin-wallet",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"main": "node install.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "webpack-dev-server --config config/webpack.dev.js",
|
||||||
|
"build:dev": "cross-env NODE_ENV=production webpack --config config/webpack.dev.js",
|
||||||
|
"build:prod": "cross-env NODE_ENV=production webpack --config config/webpack.prod.js"
|
||||||
|
},
|
||||||
|
"author": "Tlon Corp",
|
||||||
|
"license": "MIT",
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.9.0",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
||||||
|
"@babel/plugin-proposal-object-rest-spread": "^7.9.5",
|
||||||
|
"@babel/plugin-proposal-optional-chaining": "^7.9.0",
|
||||||
|
"@babel/plugin-transform-runtime": "^7.10.5",
|
||||||
|
"@babel/preset-env": "^7.9.5",
|
||||||
|
"@babel/preset-react": "^7.9.4",
|
||||||
|
"@babel/preset-typescript": "^7.13.0",
|
||||||
|
"@welldone-software/why-did-you-render": "^6.1.1",
|
||||||
|
"babel-loader": "^8.1.0",
|
||||||
|
"babel-plugin-root-import": "^6.5.0",
|
||||||
|
"clean-webpack-plugin": "^3.0.0",
|
||||||
|
"cross-env": "^7.0.2",
|
||||||
|
"file-loader": "^6.0.0",
|
||||||
|
"html-webpack-plugin": "^4.2.0",
|
||||||
|
"react-hot-loader": "^4.12.21",
|
||||||
|
"sass": "^1.26.5",
|
||||||
|
"sass-loader": "^8.0.2",
|
||||||
|
"typescript": "^4.2.3",
|
||||||
|
"webpack": "^4.43.0",
|
||||||
|
"webpack-cli": "^3.3.11",
|
||||||
|
"webpack-dev-server": "^3.10.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.10.5",
|
||||||
|
"@reach/disclosure": "^0.10.5",
|
||||||
|
"@reach/menu-button": "^0.10.5",
|
||||||
|
"@reach/tabs": "^0.10.5",
|
||||||
|
"@tlon/indigo-light": "^1.0.5",
|
||||||
|
"@tlon/indigo-react": "^1.2.8",
|
||||||
|
"bitcoinjs-lib": "^5.2.0",
|
||||||
|
"bs58check": "^2.1.2",
|
||||||
|
"buffer": "^6.0.3",
|
||||||
|
"classnames": "^2.2.6",
|
||||||
|
"css-loader": "^3.5.3",
|
||||||
|
"formik": "^2.2.0",
|
||||||
|
"fs-extra": "^8.1.0",
|
||||||
|
"lodash": "^4.17.11",
|
||||||
|
"markdown-to-jsx": "^7.0.1",
|
||||||
|
"moment": "^2.20.1",
|
||||||
|
"mousetrap": "^1.6.3",
|
||||||
|
"mv": "^2.1.1",
|
||||||
|
"promise": "^8.0.3",
|
||||||
|
"prompt": "^1.0.0",
|
||||||
|
"react": "^16.13.1",
|
||||||
|
"react-dom": "^16.13.1",
|
||||||
|
"react-router-dom": "^5.0.0",
|
||||||
|
"replace-in-file": "^4.1.1",
|
||||||
|
"style-loader": "^1.2.1",
|
||||||
|
"styled-components": "^5.2.0",
|
||||||
|
"styled-system": "^5.1.5",
|
||||||
|
"urbit-key-generation": "^0.18.0",
|
||||||
|
"urbit-ob": "^5.0.0",
|
||||||
|
"urbit-sigil-js": "^1.3.13"
|
||||||
|
},
|
||||||
|
"resolutions": {
|
||||||
|
"natives": "1.1.3"
|
||||||
|
}
|
||||||
|
}
|
52
pkg/btc-wallet/src/js/api.js
Normal file
52
pkg/btc-wallet/src/js/api.js
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
class UrbitApi {
|
||||||
|
setAuthTokens(authTokens) {
|
||||||
|
this.authTokens = authTokens;
|
||||||
|
this.bindPaths = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
bind(path, method, ship = this.authTokens.ship, appl = "btc-wallet", success, fail) {
|
||||||
|
this.bindPaths = _.uniq([...this.bindPaths, path]);
|
||||||
|
|
||||||
|
window.subscriptionId = window.urb.subscribe(ship, appl, path,
|
||||||
|
(err) => {
|
||||||
|
fail(err);
|
||||||
|
},
|
||||||
|
(event) => {
|
||||||
|
success({
|
||||||
|
data: event,
|
||||||
|
from: {
|
||||||
|
ship,
|
||||||
|
path
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
fail(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
btcWalletCommand(data) {
|
||||||
|
this.action("btc-wallet", "btc-wallet-command", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
action(appl, mark, data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
window.urb.poke(ship, appl, mark, data,
|
||||||
|
(json) => {
|
||||||
|
resolve(json);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
scry(app, path) {
|
||||||
|
return fetch(`/~/scry/${app}/${path}.json`).then(r => r.json());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export let api = new UrbitApi();
|
||||||
|
window.api = api;
|
63
pkg/btc-wallet/src/js/components/root.js
Normal file
63
pkg/btc-wallet/src/js/components/root.js
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import React, { Component } from 'react';
|
||||||
|
import { BrowserRouter, Route } from "react-router-dom";
|
||||||
|
import _ from 'lodash';
|
||||||
|
import { api } from '../api.js';
|
||||||
|
import { store } from '../store.js';
|
||||||
|
|
||||||
|
import styled, { ThemeProvider, createGlobalStyle } from 'styled-components';
|
||||||
|
import light from './themes/light';
|
||||||
|
import dark from './themes/dark';
|
||||||
|
import { Text, Box } from '@tlon/indigo-react';
|
||||||
|
//import StartupModal from './lib/startupModal.js';
|
||||||
|
//import Header from './lib/header.js'
|
||||||
|
//import Balance from './lib/balance.js'
|
||||||
|
//import Transactions from './lib/transactions.js'
|
||||||
|
|
||||||
|
|
||||||
|
export class Root extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.ship = window.ship;
|
||||||
|
this.state = store.state;
|
||||||
|
store.setStateHandler(this.setState.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(){
|
||||||
|
console.log('state', this.state);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<BrowserRouter>
|
||||||
|
<ThemeProvider theme={light}>
|
||||||
|
{// <StartupModal api={api} state={this.state}/> }
|
||||||
|
<Box display='flex'
|
||||||
|
flexDirection='column'
|
||||||
|
position='absolute'
|
||||||
|
alignItems='center'
|
||||||
|
backgroundColor='lightOrange'
|
||||||
|
height='100%'
|
||||||
|
width='100%'
|
||||||
|
px={[0,4]}
|
||||||
|
pb={[0,4]}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
display='flex'
|
||||||
|
flexDirection='column'
|
||||||
|
height='100%'
|
||||||
|
width='400px'
|
||||||
|
>
|
||||||
|
{ /*
|
||||||
|
<Header />
|
||||||
|
<Balance state={this.state}/>
|
||||||
|
<Transactions state={this.state}/>
|
||||||
|
*/ }
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</ThemeProvider>
|
||||||
|
</BrowserRouter>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
11
pkg/btc-wallet/src/js/reducers/initial.js
Normal file
11
pkg/btc-wallet/src/js/reducers/initial.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
export class InitialReducer {
|
||||||
|
reduce(json, state) {
|
||||||
|
console.log('json', json);
|
||||||
|
let data = _.get(json, 'initial', false);
|
||||||
|
console.log('data', data);
|
||||||
|
if (data) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
pkg/btc-wallet/src/js/reducers/update.js
Normal file
7
pkg/btc-wallet/src/js/reducers/update.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
|
||||||
|
export class UpdateReducer {
|
||||||
|
reduce(json, state) {
|
||||||
|
}
|
||||||
|
}
|
34
pkg/btc-wallet/src/js/store.js
Normal file
34
pkg/btc-wallet/src/js/store.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { InitialReducer } from './reducers/initial';
|
||||||
|
import { UpdateReducer } from './reducers/update';
|
||||||
|
|
||||||
|
class Store {
|
||||||
|
constructor() {
|
||||||
|
this.state = {
|
||||||
|
providerPerms: {},
|
||||||
|
provider: true,
|
||||||
|
hasWallet: true,
|
||||||
|
wallet: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
this.initialReducer = new InitialReducer();
|
||||||
|
this.updateReducer = new UpdateReducer();
|
||||||
|
this.setState = () => { };
|
||||||
|
}
|
||||||
|
|
||||||
|
setStateHandler(setState) {
|
||||||
|
this.setState = setState;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleEvent(data) {
|
||||||
|
let json = data.data;
|
||||||
|
|
||||||
|
console.log(json);
|
||||||
|
this.initialReducer.reduce(json, this.state);
|
||||||
|
this.updateReducer.reduce(json, this.state);
|
||||||
|
|
||||||
|
this.setState(this.state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let store = new Store();
|
||||||
|
window.store = store;
|
29
pkg/btc-wallet/src/js/subscription.js
Normal file
29
pkg/btc-wallet/src/js/subscription.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import { api } from './api';
|
||||||
|
import { store } from './store';
|
||||||
|
|
||||||
|
export class Subscription {
|
||||||
|
start() {
|
||||||
|
if (api.authTokens) {
|
||||||
|
this.initializeBtcWallet();
|
||||||
|
} else {
|
||||||
|
console.error("~~~ ERROR: Must set api.authTokens before operation ~~~");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeBtcWallet() {
|
||||||
|
api.bind('/all', 'PUT', api.authTokens.ship, 'btc-wallet',
|
||||||
|
this.handleEvent.bind(this),
|
||||||
|
this.handleError.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
handleEvent(diff) {
|
||||||
|
store.handleEvent(diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleError(err) {
|
||||||
|
console.error(err);
|
||||||
|
this.initializeBtcWallet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let subscription = new Subscription();
|
Loading…
Reference in New Issue
Block a user