Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 1a8db4f

Browse files
nickFranck
authored and
Franck
committed
GraphQL playground (#903)
* GraphQL playground * Move to experimental dir. Add READMEs
1 parent 1d54900 commit 1a8db4f

File tree

190 files changed

+72230
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+72230
-1
lines changed

experimental/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Origin Experimental
2+
3+
This directory contains experimental projects that are not yet in production.
4+
Code in here may not be well tested or maintained... use at your own risk!
5+
6+
- **origin-graphql** - A GraphQL interface to Origin that can be run both client and server-side
7+
- **origin-admin** - A UI leveraging origin-graphql
8+
- **origin-graphql-simple-demo** - A minimal UI leveraging origin-graphql showing listings and a buy button.

experimental/origin-admin/.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
.DS_Store
3+
public/app.*
4+
public/css/app.css
5+
public/index.html
6+
public/fonts
7+
data/db
8+
data/ipfs
9+
data/geth
10+
data/tmp
11+
NOTES
12+
src/contracts/deployed.js
13+
issuer-services/package-lock.json
14+
issuer-services/up.json
15+
issuer-services/config.json

experimental/origin-admin/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
![Origin Protocol](data/origin-header.png)
2+
3+
A UI leveraging origin-graphql. View and manage listings and offers.
4+
5+
Demo at https://www.originadm.in
6+
7+
## Usage
8+
9+
npx lerna bootstrap
10+
npm start

experimental/origin-admin/data/.gitignore

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
export const HomeshareListing = { // Unencrypted
2+
listingType: 'Home Share',
3+
title: 'Home For Rent',
4+
price: '85',
5+
currencyId: 'DAI',
6+
deposit: '50',
7+
description: 'A lovely home close to downtown Boulder',
8+
approxLocation: '40.017,-105.306',
9+
10+
pricePerDay: 100,
11+
weekendPrice: 140,
12+
cleaningFee: 50,
13+
weeklyDiscount: '5%',
14+
monthlyDiscount: '8%',
15+
extraGuestCharge: 10,
16+
taxes: '0.5% + 10',
17+
currency: 'USD',
18+
acceptedCoins: ['DAI', 'USDT'],
19+
20+
commission: '5%',
21+
22+
available: '2018/08/01-2019/04/01',
23+
unavailable: [
24+
'2018/09/01-2018/11/27',
25+
'2018/12/23-2018/12/26',
26+
'2019/02/13-2019/02/15'
27+
],
28+
29+
bedrooms: 4,
30+
bathrooms: 4,
31+
maxGuests: 8,
32+
petsAllowed: false,
33+
checkinTime: '4pm',
34+
checkoutTime: '10am',
35+
36+
contactMethods: ['Telegram', 'PGP', 'Email'],
37+
publicKey: 'ssh-rsa KH93Ud5FPUfQ+lht1UhFtM4ysVOxM...'
38+
}
39+
40+
export const HomeshareOffer = { // Encrypted with seller's public key
41+
checkin: '2019/01/12',
42+
checkout: '2019/01/14',
43+
offeredPrice: '250',
44+
currency: 'DAI',
45+
numberOfGuests: 2,
46+
specialRequests: 'I will be checking in late',
47+
}
48+
49+
export const HomeshareOfferAccepted = { // Encrypted with buyer's public key
50+
message: 'Please text me when you arrive so I can give you the key'
51+
}
52+
53+
export const HomeshareOfferFinalized = { // Unencrypted
54+
rating: '5/5',
55+
review: 'Lovely home'
56+
}
57+
58+
59+
60+
export const ForSaleListing = { // Unencrypted
61+
listingType: 'For Sale',
62+
title: 'Bike For Sale',
63+
description: 'Good condition',
64+
approxLocation: '40.017,-105.306',
65+
price: '50',
66+
currencyId: 'DAI',
67+
acceptedCoins: ['ETH', 'BTC', 'DAI'],
68+
contactMethods: [{ type: 'Telegram', channel: '0xabc123' }, { type: 'Email' }],
69+
publicKey: 'ssh-rsa KH93Ud5FPUfQ+lht1UhFtM4ysVOxM...',
70+
image: 'Qmcgwn3ADR482jPnuVtJbZTEfcaZw7hdLyzshSm2qNkLAW'
71+
}
72+
73+
export const ForSaleOffer = { // Encrypted with seller's public key
74+
title: 'Shiny kids bike',
75+
description: 'Good condition',
76+
approxLocation: '40.017,-105.306',
77+
offeredPrice: 150,
78+
currency: 'USD',
79+
acceptedCoins: ['ETH', 'BTC']
80+
}
81+
82+
export const ForSaleOfferAccepted = { // Encrypted with buyer's public key
83+
message: 'Address is 123 Fake St. Please come by tomorrow between 5pm and 7pm to pick it up - thanks.'
84+
}
85+
86+
export const ForSaleOfferFinalized = { // Unencrypted
87+
rating: '5/5',
88+
review: 'No complaints'
89+
}
90+
91+
92+
93+
export const RideShareListing = { // Unencrypted
94+
listingType: 'Car Share',
95+
title: 'Driver For Hire',
96+
price: '10',
97+
currencyId: 'DAI',
98+
approxLocation: '40.017,-105.306',
99+
carManufacturer: 'Telsa',
100+
carModel: 'Model S P100D',
101+
year: '2017',
102+
availability: 'ipfsPubSub://0x123456',
103+
commission: '7%',
104+
pricePerMile: 5,
105+
minCharge: 10,
106+
airportFixedPrice: 60,
107+
currency: 'USD',
108+
acceptedCoins: ['DAI']
109+
}
110+
111+
export const RideShareOffer = { // Encrypted with seller's public key
112+
pickup: '40.017,-105.306',
113+
pickupTime: 'ASAP (10:31am)',
114+
destination: '40.181,-105.209',
115+
offeredPrice: 20,
116+
currency: 'USD',
117+
acceptedCoins: ['ETH', 'BTC']
118+
}
119+
120+
export const RideShareOfferAccepted = { // Encrypted with buyer's public key
121+
approxPickupTime: '10:35am'
122+
}
123+
124+
export const RideShareOfferFinalized = { // Unencrypted
125+
rating: '5/5',
126+
review: 'Good driver'
127+
}
128+
129+
130+
131+
export const TicketedEventListing = { // Unencrypted
132+
listingType: 'Ticket',
133+
title: 'Ticket For Sale',
134+
price: '60',
135+
currencyId: 'DAI',
136+
artist: 'Radiohead',
137+
venue: 'The Roundhouse, London, UK',
138+
date: '2018/09/01 7:00pm',
139+
priceTiers: [
140+
{
141+
tier: 'General Admission',
142+
price: 100,
143+
availability: 500
144+
},
145+
{
146+
tier: 'VIP',
147+
price: 500,
148+
availability: 25
149+
}
150+
],
151+
currency: 'USD',
152+
acceptedCoins: ['DAI'],
153+
deliveryOptions: [
154+
{ name: 'Will Call', price: 0 },
155+
{ name: 'Email', price: 0 },
156+
{ name: 'US Mail', price: 2 }
157+
]
158+
}
159+
160+
export const TicketedEventOffer = { // Encrypted with seller's public key
161+
name: 'Bill Smith',
162+
tier: 'VIP',
163+
quantity: 2,
164+
price: 1000,
165+
pickup: 'Will Call'
166+
}
167+
168+
export const TicketedEventOfferAccepted = { // Encrypted with buyer's public key
169+
seats: [{ row: 'C', seat: '16' }, { row: 'C', seat: '17' }]
170+
}
171+
172+
export const TicketedEventFinalized = { // Unencrypted
173+
rating: '5/5',
174+
review: 'Awesome show, great venue'
175+
}
Loading
Loading

experimental/origin-admin/index.js

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import express from 'express'
2+
import serveStatic from 'serve-static'
3+
import { spawn } from 'child_process'
4+
import Ganache from 'ganache-core'
5+
import HttpIPFS from 'ipfs/src/http'
6+
import ipfsAPI from 'ipfs-api'
7+
import opener from 'opener'
8+
import fs from 'fs'
9+
// import Web3 from 'web3'
10+
11+
// import simpleIssuer from './issuer-services/_simple'
12+
13+
const HOST = process.env.HOST || 'localhost'
14+
const app = express()
15+
16+
app.get('/', (req, res) => {
17+
var html = fs.readFileSync(__dirname + '/public/dev.html').toString()
18+
res.send(html.replace(/\{HOST\}/g, `http://${HOST}:8082/`))
19+
})
20+
app.use(serveStatic('public'))
21+
22+
// try {
23+
// var { simpleApp } = require('./issuer-services/config.json')
24+
// simpleIssuer(app, { web3: new Web3(), simpleApp })
25+
// } catch(e) {
26+
// /* Ignore */
27+
// }
28+
29+
const startGanache = () =>
30+
new Promise((resolve, reject) => {
31+
try {
32+
fs.mkdirSync('./data/db')
33+
} catch (e) {
34+
/* Ignore */
35+
}
36+
var server = Ganache.server({
37+
total_accounts: 5,
38+
default_balance_ether: 100,
39+
db_path: 'data/db',
40+
network_id: 999,
41+
seed: 123,
42+
// blockTime: 3
43+
})
44+
server.listen(8545, err => {
45+
if (err) {
46+
return reject(err)
47+
}
48+
console.log('Ganache listening. Starting webpack...')
49+
resolve()
50+
})
51+
})
52+
53+
const startIpfs = (opts = {}) =>
54+
new Promise((resolve, reject) => {
55+
const httpAPI = new HttpIPFS('./data/ipfs', {
56+
Addresses: {
57+
API: '/ip4/0.0.0.0/tcp/5002',
58+
Gateway: '/ip4/0.0.0.0/tcp/9090'
59+
}
60+
})
61+
console.log('Start IPFS')
62+
httpAPI.start(true, async err => {
63+
if (err) {
64+
return reject(err)
65+
}
66+
console.log('Started IPFS')
67+
68+
if (opts.populate) {
69+
await populateIpfs()
70+
}
71+
resolve()
72+
})
73+
})
74+
75+
const populateIpfs = () =>
76+
new Promise((resolve, reject) => {
77+
var ipfs = ipfsAPI('localhost', '5002', { protocol: 'http' })
78+
console.log('Populate IPFS:')
79+
ipfs.util.addFromFs('data/fixtures', { recursive: true }, (err, result) => {
80+
if (err) {
81+
return reject(err)
82+
}
83+
result.forEach(r => console.log(` ${r.hash} ${r.path}`))
84+
resolve(result)
85+
})
86+
})
87+
88+
async function start() {
89+
await startGanache()
90+
await startIpfs({ populate: true })
91+
const webpackDevServer = spawn('./node_modules/.bin/webpack-dev-server', [
92+
'--info=false',
93+
'--port=8082',
94+
'--host=0.0.0.0'
95+
])
96+
webpackDevServer.stdout.pipe(process.stdout)
97+
webpackDevServer.stderr.pipe(process.stderr)
98+
process.on('exit', () => webpackDevServer.kill())
99+
100+
const PORT = process.env.PORT || 3000
101+
app.listen(PORT, () => {
102+
console.log(`\nListening on port ${PORT}\n`)
103+
setTimeout(() => {
104+
opener(`http://${HOST}:${PORT}`)
105+
}, 2000)
106+
})
107+
}
108+
109+
start()

0 commit comments

Comments
 (0)